In this post we will demonstrate OFBiz Content Management System usage for front end application static pages through simple content data setup and using it in a screen. This gives clients the flexibility to change the text to be shown on a static page when ever they want, without asking for any code change.
Take the example of an OFBiz e-commerce storefront web site. Often times, clients will wish to include “static” pages like About Us, FAQ, and so on. We want to empower the client to update this copy him/herself, without needing to request help from a programmer. The following example gives us a simple look at how that is done.
All the details given here are supported by the out-of-the-box (OOTB) OFBiz CMS implementation.
In this exercise we will:
- see the basic concept of DataResource and Content record.
- setup content data to embed FTL markup.
- setup a content driven screen and use it show the static content setup in data.
• Assumption: a component is already setup; here we using the name “cmsdemo” for component.
DataResource and Content records
Let’s suppose that we want to define content (that we will include in a screen) for the text “This is the text that will appear on screen.”.
First of all we have to define a DataResource representing this text. This gives you greater flexibility because you can store long texts in the textData field. If you want to embed FTL markup (directives etc…) that needs to be processed before the rendering you can achieve this using the dataTemplateTypeId attribute, in this way all the Freemarker instructions in the text will be executed before rendering the screen. Following data needs to be setup in a data file:
Now we have to create a Content record that is associated to the DataResource. No matter what type of data resource you have choosen, the Content record is the same like:
Using the element in a screen definition.
Now we can easily include the content directly inside the section of the screen definition with the following directive:
Running the content driven screen
Make sure to have an entry in ofbiz-component file for the data file created for CMS date that we created earlier in the step.
Now make sure you have main request and view defined in your controller file:
This was a very basic example of OFBiz CMS capability. We will expand on the details and demonstrate more OFBiz CMS functionality in upcoming posts. If you need help with OFBiz CMS in the mean time, contact HotWax Media today!
Pranay Pandey is Manager, Enterprise Software Development at HotWax Media (OFBiz Service Provider) and has been involved with the OFBiz project since 2007. He contributes actively to OFBiz, and also trains HotWax Media developers in OFBiz techniques and best practices.
Mike Bates founded HotWax Systems in 1997 and is our chief executive. His career in web application sales, marketing, design and development spans two decades, and he is a long time open source software advocate. He has led high-profile web software projects for numerous national and global brands and has taught web development courses at the graduate level. Mike joins other HotWax employees and advisers in periodically posting thoughts here related to HotWax Commerce, OFBiz, digital commerce, and other topics.