OFBiz Tutorials series covering the use of the OFBiz Content Management System (CMS) for front end application static pages. In this post we will cover how to set up CMS driven static pages for a website.
We will go over the following four points:
- Setup for Website Publish Point
- Setup for Decorator Content Data
- Setup for Static Content Data, and
- CMS request in Controller
In this post we are assuming that you've already set up a "cmsdemo" component following the steps in my previous post about CMS static pages.
Website Publish Point | OFBiz TutorialTo set up your website publish point in data follow the below example using "CmsDemoData.xml" as the file name.
(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)Review the code at the following url to make sure you have the webSiteId entry in web.xml for your application.
(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)Ensure that the webSiteId entry in web.xml of your application is using the following.
(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)CMS Site Main Decorator | OFBiz TutorialThe content data setup is referring to the decorator screen for a given static page.
(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)The main decorator will be set up as follows. Of course, more resources can be added but for the purpose of this tutorial, very little information is included.
(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)For setting up the cms-main-decorator screen you will use the code below.
note: the following code includes the main decorator of the site given above.(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)Decorated Content Freemaker Template | OFBiz TutorialsNow we will need to create the DecoratedContent.ftl included in the cms-main-decorator at a given location by the same name with the code shown below. This code is set up by the cms event and rendered.
${decoratedContent}
Content Data For Static Page | OFBiz TutorialsFollowing the code below, set up the content data line. This will use section-sub-content pattern and the decorator content that we've already created. This is an example of a privacy policy page.
(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)Controller Entry Creation | OFBiz TutorialTo handle CMS page requests, we'll create request entries in controller.xml.
(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)Links to CMS Pages | OFBiz Tutorial
The following code will link your CMS page with a menu on your web site.
(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)
That's it! Now load the data file you created in the CMS site data. Go to url: http//localhost:8080/cmsdemo/control/cms/root/privacypage base on the ContentAssoc record we created earlier.
(to view code for this exercise, go to: http://www.hotwaxmedia.com/apache-ofbiz-blog/category/ofbiz-tutorials/page/3/)Now you will see a privacy policy screen resulting from the above exercise.
Using this tutorial, you can add as many pages as you want that are static and easy to update in the Content Manager without modifying code.
Enterprise eCommerce using Apache OFBiz offers businesses a leg up on the competition. With the ability to reach a broad marketplace, numerous shipping options and ease of purchasing, you can poise your company for expansion in this new and exciting business environment!