Get position of slot item using ISSLOT tag

465 Views Asked by At

Actually I'm using isslotiterator and I have to use loop in loop to get the position of each slot item with the attribute counter.

I would like to know if it is possible to get the position with a <isslot>. Imagine that I have a slot with 3 entries.

So when I'm calling <isslot> in the slot item ISML I could do : #Pagelet:Position#

Then having as result : 1 / 2 / 3

2

There are 2 best solutions below

0
On BEST ANSWER

No i don't think this is possible. <isslot> does not pass the location information down of the pagelet, it just renders it. To have more control of how slot items are rendered, the isslotiterator tag was introduced.

You can get the position info from the SlotPageletAssignment object if u dont want to use a counter. Take a look at the Carousel component on the demo homepage.

app_sf_responsive_cm/release/templates/default/component/common/Carousel.isml

there u can see they use AssignmentsAlias key to get the SlotPageletAssignment

<isslotiterator Slot="#Pagelet:SubSlot("app_sf_responsive_cm:slot.carousel.items.pagelet2-Slot")#" AssignmentsAlias="CarouselPageletAssignments">
<isloop iterator="CarouselPageletAssignments" alias="CarouselPageletAssignment" counter="i">
    #CarouselPageletAssignment:Position# - #CarouselPageletAssignment:getSubPagelet#<br/>
</isloop>
1
On

Unfortunately position is not a characteristic of type Pagelet. If successfully doing this, you need to work with PageletAssignment. So instead of Pagelet:Position you need to use PageletAssignment:Position.

BUT

isslot is preparing a render dictionary for your "slot item ISML" that does not contain the assignment that was leading to this "slot item". It only contains the item itself (aka. the pagelet). Reason for that is slots can define a Pagelet Pipeline that fully dynamically determine pagelets without the need for assignments.

My suggestion: Either use isslotiterator with AssignmentsAlias (easy) or use a pagelet pipeline defined at the slotdefinition of your slot (more complicated).