I want to create a Article List wherein I want to manipulate the Article items HTML on the basis of its index. There will be only 6 articles in the list.
I created a trasnformation as shown below:
{%if(DataItemIndex==0 || DataItemIndex==3) {"<div class=\"col-lg-4 same-article-area inr slider-img-box\"><div class=\"article-inr-area five\">"} #%} {%if(DataItemIndex==1 || DataItemIndex==4) {"<div class=\"col-lg-2 same-article-area inr slider-img-box\">"} #%} {%if(DataItemIndex == 1 || DataItemIndex=2 || DataItemIndex=4 || DataItemIndex=5) {"<div class=\"article-inr-area six\">"} #%} <a href="{% GetDocumentUrl() %}"> <div class="article-inr-img"> <img class="img-responsive" src="~/TacAssets/images/home-page-img/44.png" alt="" /> </div> <div class="img-top-grd"> </div> <div class="slider-img-cnt"> <div class="lead-header"> {%ArticleName%} {% DataItemIndex %} </div> <div class="small-cnt"> {%ArticleTeaserText%} </div> </div> </a> {%if(DataItemIndex==0 || DataItemIndex==3) {"</div></div>"} #%} {%if(DataItemIndex==1 || DataItemIndex==4) {"</div>"} #%} {%if(DataItemIndex == 1 || DataItemIndex=2 || DataItemIndex=4 || DataItemIndex=5) {"</div>"} #%}
As per the transformation {%if(DataItemIndex==1 || DataItemIndex==4) {"<div class=\"col-lg-2 same-article-area inr slider-img-box\">"} #%}, <div class=\"col-lg-2 same-article-area inr slider-img-box\"> should be added to the 2 and 5 item. But its getting added to the first item also.
Here is the Page Url for the reference. http://dev.takeachallenge.org/
Please suggest.
Hello,
I have just tested it and the code gets rendered only for 2nd and 5th item. Don't you use hierarchical transformation or nested controls?
Best regards, Jan Hermann
Dewelled the root cause which is the assignment(=) operator.
{%if(DataItemIndex == 1 || DataItemIndex=2 || DataItemIndex=4 || DataItemIndex=5)
Instead I should use equals to (==) operator.
Please, sign in to be able to submit a new answer.