It might be better to use one of the render service (renderContentAsText if
you're organizing DataResource records with Content records, or
renderDataResourceAsText to go directly to DataResource). That adds a lot of
flexibility of the content management stuff.
If you go directly to the tables you can certainly get the data, but it's not
really "managed content" and you might as well use a more convenient entity (or
create one) to stuff your text into.
-David
On Mar 25, 2011, at 11:51 AM, Ruth Hoffman wrote:
> Hi Carsten:
> Here's a snippet (BeanShell, I'm afraid - but it shouldn't be to hard to
> convert) I use to display a single blog entry/article on my website. Note,
> you need the contentId. That comes from the user selecting from a list of
> articles and then passing that back via request parameter. Also, I created
> the view-entity ContentDataResourceElectronicTextView that joins the content
> -> data resource -> electronic text records together.
>
> GenericValue thisBlog =
> delegator.findOne("ContentDataResourceElectronicTextView",
> UtilMisc.toMap("contentId", article), false);
> .... stuff left out....
> context.put("blog", thisBlog);
> return;
>
> In the Freemarker template:
>
> <#assign renderedContent = StringUtil.wrapString(blog.textData) />
>
> I think I describe in pretty good detail how the OOTB OFBiz content data
> model works in the RSS document I did some time ago:
>
> http://www.myofbiz.com/ecommerce/products/PROMOTIONS/p_PUB-RSS0710
>
> Regards,
> Ruth
>
> On 3/25/11 1:15 PM, [email protected] wrote:
>> Hi Ruth,
>>
>>
>> Thanks for that bit. Any groovy script you would be able to point me to in
>> order to understand how the lookup would work?
>>
>> Regards
>>
>>
>> Carsten
>> Gesendet mit BlackBerry® Webmail von Telekom Deutschland
>>
>> -----Original Message-----
>> From: Ruth Hoffman<[email protected]>
>> Date: Fri, 25 Mar 2011 12:54:35
>> To:<[email protected]>
>> Reply-To: [email protected]
>> Subject: Re: Using CMS Elements in FTL
>>
>> Hi Carsten:
>> Are you referring to ElectronicText.textData?
>>
>> Usually content - like email body values - is either in an
>> ElectronicText.textData record pointed to by a
>> DataResource.dataResourceId and/or Content.dataResourceId or in a disk
>> file somewhere and the DataResource.dataResourceId points to that location.
>>
>> To get the content and have Freemarker render it (and not just put up
>> literal values), you can use something like:
>>
>>
>> <#assign renderedContent = StringUtil.wrapString(blog.textData) />
>>
>>
>> Where blog was placed into the context via a Groovy data prep script.
>>
>> Is that what you are looking for?
>>
>> Regards,
>> Ruth
>>
>>
>>
>> On 3/25/11 12:27 PM, Carsten Schinzer wrote:
>>> All,
>>>
>>>
>>> I am trying to customize the E-Mails and PDFs generated by OFBiz to contain
>>> managed content (like e.g. an opening text addressing the user and explaning
>>> the terms of the offer / order etc. or a closing remark including a greeting
>>> and a signature).
>>>
>>> I see that most of these contents -- especially the Formatting Object ones
>>> -- are handled and created using FTL parts.
>>> How would I thus reference a piece of managed content? Do I need to load it
>>> using a groovy script? Does anyone know a place where this is already done
>>> in the OFBiz framework?
>>>
>>> Any hint would be greatly appreciated.
>>>
>>> Thanks a lot in advance.
>>> Cheers
>>>
>>>
>>> Carsten
>>>