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

    I’ve using Ditto for a gallery site and would like to add the CSS class styling to odd and even entries.

    Ie. <div class="even"></div><div class="odd"></div>

    Is there a simple way to undertake this with ditto tags.
      Martin Sanders - Design & Web Development
      • 7231
      • 4,205 Posts
      Use the Ditto &tplAlt parameter for the alternating style:
      tplAlt
      Purpose
      
      User defined chunk to format every other document
      Options
      
          * Any valid chunk name
          * Code via @CODE
          * File via @FILE
      
      Default
      
      &tpl
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 19975
        • 429 Posts
        thanks Shane, most appreciated smiley
          Martin Sanders - Design & Web Development
          • 23299
          • 1,161 Posts
          Shane,

          I am not quite getting this. Can you explain this a little more slowly?

          Thanks!
            • 18374
            • 69 Posts
            @Photowebmax

            Shane just copied the official documentation on Ditto’s alt template.

            Layman’s terms: Whatever code you put in tplAlt will be used on every other row of Ditto’s output.

            So, if your regular tpl contained something like
            <li>[+summary+]</li>
            ...you could use tplAlt to modify this to
            <li class="alt">[+summary+]</li>


            Resulting in output of
            <li>Whatever</li>
            <li class="alt">Whatever</li>
            <li>Whatever</li>
            <li class="alt">Whatever</li>
            
              • 7231
              • 4,205 Posts
              markhurd got it right. The tplAlt will be used every other result (I guess this is the even results since they start at 1). To set it up you need 2 tpls: &tpl=`myTpl` &tplAlt=`myAltTpl` and ditto will alternate between the 2 when displaying the results.

              Tips and tricks: leave the &tpl blank and only get the odd results (or the other way around to only get the even ones). This is handy when displaying the results in cols.  wink
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don&#39;t know what it is.
                Do you, Mr. Jones? - [bob dylan]