We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21417
    • 486 Posts
    I did - that returns:
    <image source="[!imagePath!]" title="Blah 1"/>

    This is complex.
      Web design Adelaide
      http://gocreate.com.au
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Indeed. I’ll look into it and see what I can see. It’s not really complex, it’s just a matter of me getting it right!
        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
        • 36592
        • 970 Posts
        <?php
        $tv = $modx->getTemplateVar('product-image'); // use the name of your image TV here in place of 'image'
        $fullpath = $tv['value'];
        $filename = basename($fullpath);
        return $filename;
        ?>
        


        Does this getTemplateVar() return the TV value of the document which Ditto is proccessing ?
        I suppose this returns the TV value of the document which Ditto call is on...?
          • 21417
          • 486 Posts
          I’m not sure - I think Perhaps it is returning the TV value of the document which the Ditto call is on (eg in the xml document) which does not have a TV value nor a TV assigned to it?
            Web design Adelaide
            http://gocreate.com.au
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Ok, what we really need here is a custom modifier for phx.

            Make this snippet named phx:getbasename
            return basename($output);
            

            And add the phx modifier to your tpl:
            <image source="[+image:getbasename+]" title="[+pagetitle+]" />

              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
              • 21417
              • 486 Posts
              12,888 posts!
              That is amazing.

              You are a legend among legends sottwell.
              Thank you so much, that works perfectly.
              Genius springs to mind!

              I thought I would recap for non coders like me...

              create snippet called "phx:getbasename":
              <?php
              return basename($output);
              ?>


              ditto call:
              [!Ditto? id=`ditto-slide` &parents=`1` &depth=`2` &tpl=`slideshowH-row` !]


              ditto template:
              <image source="[+product-image:getbasename+]" title="[+pagetitle+]" />
              (where product-image is the name of the image template variable)
              


              Perfect - thanks sottwell, you rock!
                Web design Adelaide
                http://gocreate.com.au
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                The only genius here is whoever made PHx so easily extensible.
                  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
                  • 21417
                  • 486 Posts
                  ha - nah, take it, consider it a relative term!
                  To me you’re a coding genius.
                  Thanks again.
                    Web design Adelaide
                    http://gocreate.com.au
                    • 30202
                    • 2 Posts
                    This code has helped me 50% to what I need!

                    I want to put thumbnail images and I wanted to use the .thumb_ of the image that is made when I upload an image.

                    So right now I have ".thumb_[+image:getbasename+]" but I need to add the path to the file back in at the start, do you know how I could do that with PHx?

                    Something like "[+image:getpath+].thumb_[+image:getbasename+]"

                    Thanks for any help!
                      • 21417
                      • 486 Posts
                      Hi toastiestudio,

                      That’s a really good question, I don’t know how to do it but am very interested in the snippet as I can see how useful it would be.

                      Hopefully someone has a solution they could share with us.

                      Have a great day
                        Web design Adelaide
                        http://gocreate.com.au