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

    Does anyone know how to bespoke the Gallery ADDON to allow one to specify a bespoke LAST thumbTpl chunk? Reading the wiki it only seems to support the same TPL for ALL items?

    Basically I want to use the same TPL for ALL items APART from the last one... Is this possible? I can't use jQuery to work this out as the GALLERY call is in the HEAD to place the image URLs into a JS call...

    Any ideas?

    Think it is probs a tweak to the core ADDON code?

    This question has been answered by dubbs. See the first response.

      • 8168
      • 1,118 Posts
      Any ideas guys? Any PHP wizards out there who have bespoked the Gallery Addon to do this?
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        You might be able to do something with the :last-child pseudo-class in your CSS. http://www.quirksmode.org/css/firstchild.html
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
        • discuss.answer
          • 8168
          • 1,118 Posts
          Thanks Susan, in the end I worked out a hard-coded fix.. not sure CSS last-selector would work as the Gallery Addon call is placing the data into the HEAD of the page... also would then not work in IE7/8 as they don't support that selector...
            • 30303
            • 25 Posts
            Hi, you can make a custom snippet for adding class last every nth time.

            <?php
            
            //snippet name switch_last
            //output class last every third time
            $idx = $x + 1 ; //set start idx to 1
            
            if ($idx % 3 == 0) {
               echo 'last';
            }
            


            And then you can use it in your galItemThumb tpl.

            For example:
             <div class="portfolio one_third [[!switch_last? &x=`[[+idx]]`]]">
            
            
            [ed. note: tomek last edited this post 13 years, 8 months ago.]
              If we can really understand the problem, the answer will come out of it, because the answer is not separate from the problem.
              J Krishnamurti