We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 52078
    • 1 Posts
    Как сделать что бы idx начинал считать с нуля?

    Вызов снипета:
    <div class="bx-pager">
        [[!getImageList? 
            &tvname=`slider`
            &tpl=`@CODE:<a data-slide-index="[[+idx]]" href="#"><img src="[[+thumb]]"></a>
        `]]
    </div>


    Результат:
    <div class="bx-pager">
        <a data-slide-index="1" href="#" class="active"><img src="...."></a>
        <a data-slide-index="2" href="#"><img src="...."></a>
        <a data-slide-index="3" href="#"><img src="...."></a>
        <a data-slide-index="4" href="#"><img src="...."></a>
    </div>


    А надо так:
    <div class="bx-pager">
        <a data-slide-index="0" href="#" class="active"><img src="...."></a>
        <a data-slide-index="1" href="#"><img src="...."></a>
        <a data-slide-index="2" href="#"><img src="...."></a>
        <a data-slide-index="3" href="#"><img src="...."></a>
    </div>
    • Hi Technomaniak,

      I cant read your questtion, but i can read the code you wrote. I assume you're trying to have 1,2,3,4 instead of 0,1,2,3.

      please try this output modifier
      :add=`1`


      So it looks like this:
      <div class="bx-pager">
          [[!getImageList? 
              &tvname=`slider`
              &tpl=`@CODE:<a data-slide-index="[[+idx:add=`1`]]" href="#"><img src="[[+thumb]]"></a>
          `]]
      </div>


      I hope I understood your question right.