Search the FirstSpirit Knowledge Base
Hello,
In my project, I have Set and List in the template and I need to compare the Set's value with the List's value. So I am using
$CMS_FOR$ to do the iterate the Set and then compare each vale with the List. If I find any Match I should come out of the
loop (there is no need to continue the loop). But I don't how to come out of the CMS_FOR tag.
Please let me know how to jump out of the loop or if there is any way to achieve this.
Thanks in Advance !!!!
-
Vasanth
Hi Vasanth,
it's not possible in the current version, but it will be available with FirstSpirit5.
Here's the feature request (german only):Möglichkeit CMS_FOR-Anweisung zu verlassen
Hi vasanth,
Yes it's not possible in the current version, but you can use $CMS_SET(count,"1")$ and some condtions in side the for loop to reach your scenario.
Please see the example code, here i need to show latest 2 articles from all article categories and region based. I used link templates for the region , so i can't able to filter using query. So, i used this scenario...
I hope it help for you.......
eg:
$CMS_FOR(alist,news_center_list)$
$CMS_FOR(for_link, alist.display_ref)$
$CMS_IF((for_link.text).equals(region.toString) && !(count).equals("2"))$
<table cellspacing="0" cellpadding="0" border="0" class="news-item">
<tr>
<td>
<div class="news-item-date">
<div class="news-arrow"><!-- Managed from css --></div>
<div class="news-day">$CMS_VALUE(alist.publish_date.format("dd"))$</div>
<div class="news-month">$CMS_VALUE(alist.publish_date.format("EEE"))$</div>
<div class="news-year">$CMS_VALUE(alist.publish_date.format("yyyy"))$</div>
</div>
</td>
<td width="100%">
<p>
$CMS_IF(#global.preview)$
$-- Preview--$
<a href="$CMS_REF(for_link.lt_referenace,contentId:alist.id)$"> $CMS_VALUE(alist.title)$ </a>
$CMS_ELSE$
$-- Portal --$
<a href=$CMS_RENDER(template:"portal_navigation", targetUid:ref(for_link.lt_referenace,contentId:alist.id).target.getUid(), targetUrl:ref(for_link.lt_referenace,abs:1,contentId:alist.id).url, linkContent:set_linkContent,contentId:alist.id)$> $CMS_VALUE(alist.title)$ </a>
$CMS_END_IF$
</p>
</td>
</tr>
</table>
$CMS_IF((count).equals("0"))$
$CMS_SET(count,"1")$
$CMS_ELSE$
$CMS_SET(count,"2")$
$CMS_END_IF$
$CMS_END_IF$
$CMS_END_FOR$