Message Boards

How to count occurrences of a fragment in a page? (collection display)

thumbnail
Fernando Fernandez, modified 2 Years ago.

How to count occurrences of a fragment in a page? (collection display)

Expert Posts: 396 Join Date: 8/22/07 Recent Posts

Hi all,

I'm using the new features from 7.4 (fragments, collection display, etc.) instead of asset publisher with widget and structure templates. Just because. :-)

I've defined a collection of webcontents and added a collection display on my content page. I also defined a fragment to be used on the collection display and it's working (almost) fine.

The problem is that our design requires us to alternate left/right aligment on even/odd items from the collection. Not a problem with widget templates, but I don't see a way of doing this with the collection display, which is not templeatable. Or is it?

I thougth I could put a counter on some attribute on the request or session, but these objects seem not to be available inside the fragment freemarker.

Any ideas?

TIA

Fernando