For a project I'm using Sitecore CMS. The HMTL output.
<div class="carousel-item" item-position="1">
...
</div>
<div class="carousel-item" item-position="2">
...
</div>
<div class="carousel-item" item-position="3">
...
</div>
Each div-element represents a Sitecore component at placeholder carousel. Attribute item-position is the current position of the Sitecore component at the placeholder. Keep in mind that Sitecore rules must be executed before a component is visible at the website.
Does anyone know how I could calculate the attribute item-position (1, 2, 3 etc.)?
Thanks a lot.
Jordy
The easiest way is probably to manually count everytime you execute a component and store the counter value in
Sitecore.Context.Items
collection, which is shared for one single request. Something like this:Then get the current component count in your components with this method.