Jahia Dev Forum > status variable...

0 (0 Good)
0 (0 Bad)

status variable for iteration on template:containerList tag

by  testa »  2011/06/07 20:40

Is there a way to get current iteration count inside the <template:container > block, so that I can manipulate formatting?
<template:containerList name="navigationLink" id="navigationLink" >
<template:container >
<li><template:field name="link" display="true" /></li>
</template:container>
....

How do I get status variable of iteration so that I can figure out the current loop count similar to jstl. I am trying to iterate page field, it is returning wrong value.

<c:forEach items="${navigationLink.containers}" var="entry" varStatus="status">
${entry.fields["hmhedu_templates_productsimple_titleContent_navigationLink_link"].title} -
${entry.fields["hmhedu_templates_productsimple_titleContent_navigationLink_link"].value} -
${entry.fields["hmhedu_templates_productsimple_titleContent_navigationLink_link"]} -
</c:forEach>

Here is the output of the jsp.
link - 822 - org.jahia.data.beans.FieldBean@4f53de

How do I get the correct page object to display link name and url? or better how to get row count or varstatus variable inside the <template:container > tag.

Thanks,

  (testa)

Number of messages  12
Registration date
0 (0 Good)
0 (0 Bad)

Re: status variable for iteration on template:containerList tag

by  pap@commaro.com »  2011/06/07 20:40

Hello,

actually the same varStatus attribute and variable as used in the JSTL forToken can also be used in <template:container> :

<template:containerList ...>
<template:container varStatus="status">
</template:container>
</template:containerList>

If you use <c:forEach> instead you will not benefit from the automatic HTML fragment caching, which will be helpful for performance. The JSTL expression for getting the URL in your case would be:
${entry.fields["hmhedu_templates_productsimple_titleContent_navigationLink_link"].url}
and the link name
${entry.fields["hmhedu_templates_productsimple_titleContent_navigationLink_link"].title}

But you should rather do it with the tags as they are existing.

Regards,
Benjamin

Benjamin Papez (pap@commaro.com)

Number of messages  220
Registration date
Contact
Share
Feedback

Get in touch

Whether you are a current user or if you are just evaluating Jahia, we are here to help.

Contact us

Share this page