OFBiz Tutorial-Using CMS for Static Web Pages

Pranay PandeyPublished: Updated:

In my last post regarding usage of CMS for Front End application we saw how to setup simple static content page using contentId in OFBiz screen definition. You just need to setup the content data and controller entry to make it work.

Now we will see how to setup CMS driven static page for a website. Following four steps are going to be the magic:

  • WebSite Publish Point Setup
  • Decorator Content Data Setup
  • Static Content Data Setup
  • CMS request in Controller

Assumption: A component is already setup; here the name of the component is “cmsdemo” . If you have not done that already please go through my last post OFBiz tutorial on CMS usage for front end application.

Setting up Website Publish Point

Its easy to setup Website publish point in data. Below is an example of  how to do this in the content data file, in this case the name of the file is CmsDemoData.xml:

Also make sure you have webSiteId entry in web.xml of your application as shown below:

Setting CMS Site Main Decorator

Content Data

Content data setup refers to the decorator screen for static pages:

Screens

Setup the main decorator for your site as shown below, it can have more resources included, but right now it has very little information:

Now you need to setup the cms-main-decorator screen as shown in the code below which will include the above given main decorator of the site.

Decorated Content Freemarker Template

The DecoratedContent.ftl that you included in your cms-main-decorator, shown above, needs to be created at a given location by the same name with only the code as shown below, which is setup by the cms event and rendered:

Setup Content Data for Static Page

Setup the content data line like the code below, which will use section-sub-content pattern and will use the decorator content that we created in an earlier step. Here I have given an example of how you can setup a privacy policy page for your site.

Creating Controller Entry

Now create request entries in controller.xml to handle CMS page requests as shown below:

Provide links to CMS Page/Pages

Now its time to link CMS page with a menu on your web site as shown below:

You are done. Just load the data file which you created in CMS site data. Browse the url: http://localhost:8080/cmsdemo/control/cms/root/privacyPage which is based on ContentAssoc record we created earlier for privacy page as mentioned below:

In the resultant screen you will see following page as per your data setup done:
FinalImage

 

 

 

 

 

 

 

 

 

 

This way you can add in as many pages as you want for a website which are static in nature and let your client feel good when it comes to make any changes in content. They can simply login to Content Manager and can update the content easily without any code modification activity at any point of time.

Pranay Pandey About Pranay Pandey
Pranay Pandey has been in the software industry since 2006. He specializes in Enterprise Software Design and Development. At HotWax he currently leads the effort of architecting quality software products and training resources. He continues to be dedicated to the Apache OFBiz open source project since 2007 and became a committer in 2014. He leads our internal training programs in Apache OFBiz, ERP and new technologies under the roof of HotWax University. He is an Electronics graduate and has a masters degree in Computer Applications from Rajeev Gandhi Technical University, Bhopal (M.P.) India. He loves learning and sharing knowledge. He believes that one of the keys to success in this industry is to "keep learning". His hobbies are reading, writing, walking, running, cycling, cooking and watching science fiction movies.

Leave a Reply

Your email address will not be published. Required fields are marked *