This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
I have list in Slightly. From the list i am trying to print only index =2. Can some one help me with this. Thanks in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
<div data-sly-list.tab="${nav.tabs}" data-sly-unwrap>
<div data-sly-test="${tabList.index == 2}" data-sly-unwrap>
<div class="${tabList.index}">Its two</div>
</div>
</div>
Hi,
Try something like this.
< dl data-sly-list = "${currentPage.listChildren}" > < dt >index: ${itemList.index}</ dt > < dd >value: ${item.title}</ dd > </ dl > |
Code samples are intended for illustration purposes only
The following default variables are available within the scope of the list:
item: The current item in the iteration.
itemList: Object holding the following properties:
index: zero-based counter (0..length-1).
count: one-based counter (1..length).
first: true if the current item is the first item.
middle: true if the current item is neither the first nor the last item.
last: true if the current item is the last item.
odd: true if index is odd.
even: true if index is even.
Defining an identifier on the data-sly-list statement allows you to rename the itemList and item variables. itemwill become <variable> and itemList will become <variable>List.
< dl data-sly-list.child = "${currentPage.listChildren}" > < dt >index: ${childList.index}</ dt > < dd >value: ${child.title}</ dd > </ dl > |
Thanks,
Shivamurthy Mn
thanks. Got it. I will post the solution early.
<div data-sly-list.tab="${nav.tabs}" data-sly-unwrap>
<div data-sly-test="${tabList.index == 2}" data-sly-unwrap>
<div class="${tabList.index}">Its two</div>
</div>
</div>
Shorter version.
<sly data-sly-list.tab="${nav.tabs}">
<div data-sly-test="${tabList.index == 2}" class="${tabList.index}">Its two</div>
</sly>
<sly data-sly-list.hero="${model.heading}">
<sly data-sly-test="${heroList.index == 2}" >
<div class="${heroList.index}">your content is two</div>
</sly>
</sly>
Views
Likes
Replies