We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25898
    • 20 Posts
    Hi there

    this is my chunk

    <li class="[+ditto_iteration:math=`(?+1)%2`:is=`0`:then=` color-background-portfolio-twee`:else=`color-background-portfolio`+]"><a href="[~[+id+]~]">[+pagetitle+]</a></li>


    I want this:

    <li class="color-background-portfolio"></li>
    <li class="color-background-portfolio-twee"></li>
    <li class="color-background-portfolio-drie"></li>
    <li class="color-background-portfolio"></li>
    <li class="color-background-portfolio-twee"></li>
    <li class="color-background-portfolio-drie"></li>

    the first and seconds works because of the chunck... but i want the 3 and the 6 to be a other collor. i do i do that?

    please help... thnx smiley
      • 16278
      • 928 Posts
      You could use a custom PHX modifier to achieve this (and make it a more flexible solution than putting the logic into the PHx call itself).

      Create a snippet called phx:mColor
      <?php
      // phx:mColor
      // select colour setting according to position in list
      // position = $output from ditto_iteration placeholder
      
      $colorStrings = array(
      'color-background-portfolio',
      'color-background-portfolio-twee',
      'color-background-portfolio-drie'
      );
      
      $nStrings = count($colorStrings);
      
      $color = $colorStrings[$output % $nStrings];
      
      return $color;
      ?>

      Feed it the output of the ditto_iteration placeholder within your template chunk:
      <li class="[+ditto_iteration:mColor+]"><a href="[~[+id+]~]">[+pagetitle+]</a></li>

      and Bob, as they say, is your uncle.
      wink KP
        • 25898
        • 20 Posts
        OMFG it works laugh Thank you so MUCH