We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19975
    • 429 Posts
    I’m currently building a Ditto list within a popular website and need to ensure the my Ditto addition always shows two even columns. To achieve this effect I would like to use PHx to display a graphic banner should the first column be longer than the second thus making both column equal in length.

    As such I could use the [+total+] pagination placeholder value and then use this value in a PHx script to detect if the pagination number is odd and then display a banner if needed. Unfortunately as there is a pre-existing issue with Ditto pagination not working on cached pages with PHx present I can only perform this script on non-cached pages. As the site is very busy caching is essental, so this leads me to question whether there are any other ways detect whether a is list even or odd?

    Thanks for any help smiley

      Martin Sanders - Design & Web Development
      • 26931
      • 2,314 Posts
      maybe splitPagination will work instead http://modxcms.com/extras/package/97 ... or a little snippet with the same logic as your PHX statement
        • 19975
        • 429 Posts
        Thanks for feedback sharkbait,

        How would it be possible to enable the Pagination [+total+] placeholder within a cached page with PHx present?

        It’s not clear how the linked snippet would help us with this issue as it only splits the Pagination which we don’t need. If there is an alternative placeholder we can use to show the quantity of listed items within a Ditto call this would help. Additionally we have more than 1 Ditto per page.


          Martin Sanders - Design & Web Development
          • 26931
          • 2,314 Posts
          what about Ditto iteration in combination with phx:evenodd http://wiki.modxcms.com/index.php/PHx/CustomModifiers#phx:evenodd within the Ditto template ( using Dittos own PHX logic )?
            • 19975
            • 429 Posts
            I already have the iteration working, however how do I pass the iteration value to either the page template to action a PHx script [+phx:if=``:then=``+] or have the Ditto include an extra banner item if the list is uneven?

            Example Ditto call

            Odd number of pages:
            <ul>
            <li class="even">page</li><li class="odd">page</li>
            <li class="even">page</li><li class="odd">page</li>
            <li class="even">page</li><li class="odd">show banner to make even</li>
            </ul>

            When even number of pages:
            <ul>
            <li class="even">page</li><li class="odd">page</li>
            <li class="even">page</li><li class="odd">page</li>
            <li class="even">page</li><li class="odd">page</li>
            </ul>

            PS. I’ll also PM you the site link.

              Martin Sanders - Design & Web Development
              • 26931
              • 2,314 Posts
              i guess i got a solution, e.g.

              use &tpl=`iteration` &tplLast=`iterationlast` in your Ditto call.

              then {{iteration}}
              <p>[+pagetitle+]</p>


              and {{iterationlast}}
              [+total:math=`(?+1)%2`:is=`0`:then=`<p>last template odd: [+pagetitle+]</p>`:else=`<p>[+pagetitle+]</p>`+]


              hope i got it right wink
                • 19975
                • 429 Posts
                Thanks Jan, it worked like a charm, perfect smiley
                  Martin Sanders - Design & Web Development
                  • 26931
                  • 2,314 Posts
                  pleasure, glad i could help smiley