We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19257
    • 141 Posts
    I want to use this flickr gallery tutorial http://net.tutsplus.com/tutorials/php/how-to-create-a-photo-gallery-using-the-flickr-api on my modx site, but its not working, I’m guessing I have to convert the php files to snippets or plugins. This would be my first snippet and I’m kinda stuck, the thumbnail alt tags show up but not the photos themselves. Also I read in the modx wiki http://wiki.modxcms.com/index.php/Creating_Snippets that you shouldnt include html in a snippet. ??

    What I did was create a snippet out of the index file and call the snippet in a modx document.
      • 3749
      • 24,544 Posts
      Yes, all PHP code has to go in a snippet.

      You can put HTML in the snippet if you need to. It just makes the site harder to maintain because you have to rewrite the snippet every time you want to change the output format.

      The way to do it is to use an $output variable and add the HTML to it at various points in the code:

      $output .= '<p>some HTML</p>';


      Then put this at the end of the snippet:

      return $output;


      The usual way to avoid that (and the "correct" MODx way) is to put all the HTML in a Tpl chunk with placeholder tags for all the values that the snippet will set. Then in your snippet, you can either set the placeholders with $modx->setPlaceholder(’placeholderName’, ’value’) or put the values into an associative array and send the array to $modx->getChunk():

      $placeholders = array(
         'placeholder1'=>'some value',
         'placeholder2 => 'some other value', 
      );
      

      With the first method, the snippet would end with:

      return $modx->getChunk('TplChunkName');


      With the second, it would be:

      return $modx->getChunk('TplChunkName', $placeholders);


      Hope that makes sense. 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
        • 18959
        • 6 Posts
        Just to let you know, phpFlickr needs the pear PHP system as far as I know (google it if you want to know about it), and when you try to install it, it will mess up your entire MODx/site system since it isn’t very compatible with other packages on a website. Messed up my own website, I had to use my backup index.php file to fix my website.

        Hope you find someway to get it work, but I found this simple solution, which you can edit and use as you wish (don’t forget to change the API key and secret):
        http://modxcms.com/forums/index.php/topic,61088.0.html
          • 32244
          • 1 Posts
          Can someone explain me how to start?
          I want to make a flick gallery at my site too.
          What I want is pretty much what the tutorial does (posted above by MDragon)

          I’m working with modx revolution, and I am kind of newbie, so I am learning every day.
          I was hoping it would work easy like installing a gallery package, but unfortunately it isn’t.

          Can someone tell me step by step what to do, because I am kind of clueless at the moment.