We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13137
    • 204 Posts
    I am trying to use a Snippet in Ditto that calls an image from a TV and creates a thumb.
    If doc does not have image, a default one is supplied.
    What I have at the moment is:
    <?php
    $TVname = isset($tv)?$tv:'Main-Image'; // Include TV name
    if( $TVarray = $modx->getTemplateVarOutput(array($TVname)) ){
    	$tvOutput = $TVarray[$TVname];
    	if(empty($tvOutput)) return '<img src="assets/images/logotipo.jpg" alt="[+title+]">'; // if TV is empty, else do... 
    	return '<img src="[[phpthumb? &input=`[*Main-Image*]` &options=`w=100`]]" alt="[*title*]">'; // Display Code with TV included
    }
    return '';
    ?>
    


    But when the page is rendered, it displays the current pages image and not the ones created by Ditto.

    How can I tell it to grab the TV from the correct pages IDs?

    PS. Using Evo v1.0.15
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Looks like you are using [*Main-Image*], which calls from the current resource, instead of the Ditto placeholder [+Main-Image+], which will call from the resource Ditto is processing in the loop.
        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
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Doesn't Ditto have phx built-in for that sort of thing?
          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