Approaches to write simple conditional logic in presentation template

As there is no direct way of writing the logic inside the presentation template , we need do this indirectly in different ways.  Following are two most common ways of handling logic before presenting the content from presentation template.

1. Create JSP Component that refers JSP contains logic and display the content
2. Write JavaScript Code directly in the presentation template (or write it in the Separate HTML components or Content and refer from presentation).

Example scenario

1. Have one authoring Template called "News_AT" and one presentation template called "News_PT".
2. "Type of News" option selection Element in above template
3. Created different types of News content (HR, Business, Technical) and content is spread across the multiple site areas.
4. Mapping between the "News_AT" and "News_PT" defined at Site level (As content spread across the Site).

To display different presentations based on the value selected "Type of News" element in the content ,write below code in presentation template

<div id="pattern1" style="display:None">
    <element key=""..../>
    some HTML Design  based on the elements

<div id="pattern2" style="display:none">
    <element key=""..../>
    some HTML Design  based on the elements

function testFunc(){
  var typeOfNews="<element key="Type of News" context="current"/>";
  if("HR" == typeOfNews){
  }else if("Technical" == typeOfNews){


No comments:

Post a Comment