We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20014
    • 200 Posts
    I had tried that, but it hadn’t seem to work either, returning a chunk for an id wasn’t a problem, the problem was it didn’t seem to like the fact that chunk contained another snippet, for some reason using a tv worked...scratching my head.
      • 20014
      • 200 Posts
      Susan, you had me thinking, I had gone about this all wrong, I tried it on a single page and worked:

      <?php
      
      $current_docid = $modx->resource->get('id');
      $output ='';
      
      if($current_docid ==4){
          $output .='[[$randomimagephotos3]]';
      }
      return $output;
      ?>


      I simply created a snippet, inserted it into the template as you said, no tvs or anything, I think I had tried this before... huh

      as always Susan you are the best!
        • 3749
        • 24,544 Posts
        Quote from: modxlearner123 at Aug 12, 2010, 01:57 PM

        Susan, you had me thinking, I had gone about this all wrong, I tried it on a single page and worked:

        <?php
        
        $current_docid = $modx->resource->get('id');
        $output ='';
        
        if($current_docid ==4){
            $output .='[[$randomimagephotos3]]';
        }
        return $output;
        ?>


        I simply created a snippet, inserted it into the template as you said, no tvs or anything, I think I had tried this before... huh

        as always Susan you are the best!
        Depending on the caching scheme, you might want to change it to:

        $output .=’[[!$randomimagephotos3]]’;

        if you run into problems with it constantly showing the same ouput.


        BTW, If there’s only one snippet, that’s good. But if there are several and you’re using the number to identify which one is called, you could also use a single snippet and send a parameter (or several parameters) to it with something like this:

        $output .= $modx->runSnippet($randomimagephotos, array($num=>'3'));


        The variable $num would be available (and set to 3) in the randomimagephotos snippet.

        And, yes, Susan is the best. wink


          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 32699 ☆ A M B ☆
          • 427 Posts
          W. Shawn Wilkerson Reply #14, 16 years ago
          I apologize for being so very late on this thread, but I was wondering if the random image snippet I wrote Nov 2009 would be of interest to you:

          http://www.shawnwilkerson.com/modx-revolution/modx-snippets/snippet-randomimage.html
            Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

            Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com