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

    I am using EVO 1.0.4 with Ditto 2.1.0.

    I am using ditto to create a simple menu to insert image info into an xml document for a monoslideshow flash slideshow.

    The menu is created from pages that contain just a page title and an image TV.

    How do I include only the image name (eg name.jpg) not the full path (eg assets/images/slideshow/name.jpg)?

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


    My template for the image row is:
    <image source="[+product-image+]" title="[+pagetitle+]" />


    The product-photo TV is a TV with input type Image so that the end user can upload and view the image on the page in the manager.

    The current result for the images menu is :
    <image source="assets/images/slideshow/name.jpg" title="blah 1" />
    <image source="assets/images/slideshow/anothername.jpg" title="blah 2" />
    <image source="assets/images/slideshow/differentname.jpg" title="blah 3" />
    


    I need the end result to look like:
    <image source="name.jpg" title="blah 1" />
    <image source="anothername.jpg" title="blah 2" />
    <image source="differentname.jpg" title="blah 3" />


    Any ideas?

    Thanks in advance.
      Web design Adelaide
      http://gocreate.com.au
      • 15152
      • 360 Posts
      One simple way would be to create a second TV asking for the name of the file and insert that.
        There are no boring projects. Only boring executions. ~ Etzkorn
        www.impress-design.com
        • 21417
        • 486 Posts
        Thanks JWMSales - that’s a great suggestion.

        It might be subject to client keying / pasting error though??

        Can anyone think of a way to do it dynamically?

        The folder path is always going to be: assets/images/slideshow/
          Web design Adelaide
          http://gocreate.com.au
          • 22427
          • 793 Posts
          I need the end result to look like:
          <image source="name.jpg" title="blah 1" />
          Why there is a need for that?
            • 21417
            • 486 Posts
            Unfortunately monoslideshow needs the folder path up the top:
            <album itemPath="/assets/images/slideshow/">

            and no folder path with the image:
            <image source="name.jpg" title="blah 1" />

            otherwise it doesn’t work
              Web design Adelaide
              http://gocreate.com.au
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Use a snippet to process the TV output.
                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
                good thinking. if I knew how to do that I wouldn’t be asking how to do it.

                Anyone out there know how to write the snippet for me? Happy to paypal.
                  Web design Adelaide
                  http://gocreate.com.au
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  <?php
                  $tv = $modx->getTemplateVar('image'); // use the name of your image TV here in place of 'image'
                  $fullpath = $tv['value'];
                  $filename = basename($fullpath);
                  return $filename;
                  ?>
                  

                    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
                    Thanks Susan, wow - that looks awesome and is very much appreciated.

                    Alas I am an absolute coding dunce!

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


                    I changed my template to:
                    <image source="[[imagePath]]" title="[+pagetitle+]" />


                    And I created a snippet called imagePath:
                    <?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;
                    ?>
                    


                    This returns a blank for the images:
                    <image source="" title="Blah 1"/>


                    I also tried without success:
                    [*product-image*]
                    [+product-image+]

                    Maybe there is hope for me somewhere but I don’t rate my chances as a coder!
                      Web design Adelaide
                      http://gocreate.com.au
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Hmm. Did you try the snippet uncached [!...!]?
                        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