Using CMS Elements in FTL

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using CMS Elements in FTL

c.schinzer
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
Reply | Threaded
Open this post in threaded view
|

Re: Using CMS Elements in FTL

Ruth Hoffman-2
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
>
Reply | Threaded
Open this post in threaded view
|

AW: Re: Using CMS Elements in FTL

c.schinzer
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 <[hidden email]>
Date: Fri, 25 Mar 2011 12:54:35
To: <[hidden email]>
Reply-To: [hidden email]
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
>

Reply | Threaded
Open this post in threaded view
|

Re: AW: Re: Using CMS Elements in FTL

Ruth Hoffman-2
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, [hidden email] 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<[hidden email]>
> Date: Fri, 25 Mar 2011 12:54:35
> To:<[hidden email]>
> Reply-To: [hidden email]
> 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
>>
Reply | Threaded
Open this post in threaded view
|

Re: AW: Re: Using CMS Elements in FTL

David E. Jones-2

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, [hidden email] 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<[hidden email]>
>> Date: Fri, 25 Mar 2011 12:54:35
>> To:<[hidden email]>
>> Reply-To: [hidden email]
>> 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
>>>

Reply | Threaded
Open this post in threaded view
|

Re: AW: Re: Using CMS Elements in FTL

Ruth Hoffman-2
Hi David:
Thanks for the info.

For me, I have found that having more control over my data is the
preferred way to go. I've been burnt on several occassions when I used
OOTB services and then struggled (for way too many hours) with SECAs
that, in the end, made the original service unusable. Not to say that
the rendering services wouldn't work in my case - for they might. But it
is much faster for me to use direct database calls (plus, I get a
thorough understanding of the data model when I do it this way) and,
more importantly easier for me to maintain.

I guess I don't understand your comment about "managed content"? How do
the rendering services manage content? Could you elaborate?

Regards,
Ruth

On 3/25/11 6:01 PM, David E Jones wrote:

> 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, [hidden email] 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<[hidden email]>
>>> Date: Fri, 25 Mar 2011 12:54:35
>>> To:<[hidden email]>
>>> Reply-To: [hidden email]
>>> 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
>>>>
>