DataItemIndex in Transformation (Text/XML)

Aashish Khandelwal asked on March 15, 2015 10:32

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.

Recent Answers


Jan Hermann answered on March 17, 2015 13:35

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

0 votesVote for this answer Mark as a Correct answer

Aashish Khandelwal answered on March 17, 2015 16:14

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.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.