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

    I’ve searched high and low but can’t find de answer to the problem i’m having with this snippet in ditto. I have used this code http://alistairrobinson.co.uk/a-nice-and-simple-photo-gallery-solution-for-modx/ to create an image with thumbnail files on the project pages. But I also want to display the thumbnail version of that image in a carousel on the homepage.

    The problem is that the snippet only generates the image on the first ditto result. So the ditto call is working, the snippet is working for the first ditto result but not for the other results. I’ve tried the cache uncache options but that didn’t have any effect. I recoded the snippet multible times but i’m no programmer, so no luck. I hope someone can point out the problem.



    My ditto call:
    <div id="project-zapper">
    <ul id="mycarousel" class="jcarousel-skin-ie7">
    [!Ditto? &parents=`14,16,19,22,27` &total=`9` &randomize=`1` &noResults=` ` &tpl=`ditto-project-slider`!]	
    </ul>
    </div>
    


    My ditto template chunk:
    <li><a href="[~[+id+]~]" title="[+title+]">[[test? &docID=`[+id+]`]]</a> 
    <h4><a href="[~[+id+]~]" title="[+title+]">[+type-woning+] <br/>[+plaats+]</a></h4> 
    <a href="[~[+id+]~]" title="[+title+]">Bekijk dit project</a>
    </li>
    


    The snippet code:
    <?php
    include_once($modx->config['base_path'].'assets/bin/config.php');
    
    //Get name of the thumnail folder
    $balk_folder = $modx->config['site_url'].constant('THUMBS_FOLDER');
    
    //Get the input from the image tv
    $docID = (isset($docID)) ? $docID : $modx->documentIdentifier;
    $tvout=$modx->getTemplateVarOutput('body_photo',$docID);
    
    $path = $tvout['body_photo']; 
     
    //No input found show niks 
    $bhtml = 'niks';
    
    //Else rewrite normal path to thumnail path and output
    if(!empty($path)) {
      $full_path = $modx->config['base_path'].$path;
      $file_name = basename($full_path);
      $url = $balk_folder.$file_name;
      
      $bhtml = '<img src="'.$url.'" alt="" width="122" height="99" />';
     
     
    }
    echo $bhtml;
    
    ?>
    



    Any ideas?
    Thx in advance, and greetings, Lodewijk

      • 4310
      • 2,310 Posts
      A wild guess but maybe worth changing :
      include_once($modx->config['base_path'].'assets/bin/config.php');
      to :
      include($modx->config['base_path'].'assets/bin/config.php');

        • 17369
        • 0 Posts
        Thank you for the reply!

        I changed the include_once to include but it’s still not working, sadly. Any other suggestions?

        I’m using modx version 1.0.5 with ditto 2.1.0 btw
          • 4310
          • 2,310 Posts
          Another long shot try
          return $bhtml;
            • 17369
            • 0 Posts
            You’re first shot was right after all. In modx itself I also used include_once to call the php file. It’s working now, thank you smiley