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,

  • status variable for iteration on template:containerList tag
    2011/07/08 15:23

    testa <p> Is there a way to get current iteration count inside the &lt;template:container &gt; block, so that I can manipulate formatting?<br /> &lt;template:containerList name=&quot;navigationLink&quot; id=&quot;navigationLink&quot; &gt;<br /> &lt;template:container &gt;<br /> &lt;li&gt;&lt;template:field name=&quot;link&quot; display=&quot;true&quot; /&gt;&lt;/li&gt;<br /> &lt;/template:container&gt;<br /> ....<br /> <br /> 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.<br /> <br /> &lt;c:forEach items=&quot;${navigationLink.containers}&quot; var=&quot;entry&quot; varStatus=&quot;status&quot;&gt;<br /> ${entry.fields[&quot;hmhedu_templates_productsimple_titleContent_navigationLink_link&quot;].title} -<br /> ${entry.fields[&quot;hmhedu_templates_productsimple_titleContent_navigationLink_link&quot;].value} -<br /> ${entry.fields[&quot;hmhedu_templates_productsimple_titleContent_navigationLink_link&quot;]} -<br /> &lt;/c:forEach&gt;<br /> <br /> Here is the output of the jsp.<br /> link - 822 - org.jahia.data.beans.FieldBean@4f53de<br /> <br /> 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 &lt;template:container &gt; tag.<br /> <br /> Thanks,</p>

  • Number of messages  12
    Registration date Jun 7, 2011
    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