CMS_INPUT_DOM - Listoutput without spanning 'p' tags

hoebbel
Crownpeak employee
Crownpeak employee
3 7 2,246

You can use lists within the CMS_INPUT_DOM component. Unfortunately these lists have to be defined within a section formattemplate, which puts unneeded tags within the output

<p>
    <ul>
        <li>...</li>
        <li>...</li>
    </ul>
</p>


To get rid of these unnecessary tags, you can put the following code within all of your section formattemplates and in the ul-formattemplate:

sectionformattemplate:

$CMS_IF(!#content.toString.trim.equals(""))$$CMS_SET(listLayer,0)$$CMS_SET(startTag,"<p>")$$CMS_SET(endTag,"</p>")$$CMS_SET(output,startTag + #content + endTag)$$CMS_VALUE(output.replaceAll(startTag+endTag,""))$$CMS_END_IF$


ul-formattemplate:

$CMS_IF(listLayer==0)$$CMS_VALUE(endTag)$$CMS_END_IF$$CMS_SET(listLayer,listLayer+1)$$CMS_IF(#list.style==2)$<ol>$CMS_VALUE(#content)$</ol>$CMS_ELSE$<ul>$CMS_VALUE(#content)$</ul>$CMS_END_IF$$CMS_SET(listLayer,listLayer-1)$$CMS_IF(listLayer==0)$$CMS_VALUE(startTag)$$CMS_END_IF$

Explanation:

$CMS_IF(!#content.toString.trim.equals(""))$ --> checks, if the section contains more then just white-spaces. Otherwise it will not be rendered.
$CMS_SET(listLayer,0)$ --> defines a counter to check, if the actual list is the outer list. Otherwise we do not need to eliminate the outer tags.
$CMS_SET(startTag,"<p>")$$CMS_SET(endTag,"</p>")$ --> definition of the tags which should be used for the appropriate section. You have to adjust the content 😉
$CMS_SET(output,startTag + #content + endTag)$$CMS_VALUE(output.replaceAll(startTag+endTag,""))$ --> Eliminates all empty (not needed) tags of the section formattemplate [in the example <p></p>]

Tested with FirstSpirit Version 4.2R2

7 Comments
Version history
Last update:
‎07-13-2010 05:43 AM
Updated by: