We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29839 ☆ A M B ☆
    • 66 Posts
    Hello, i’m in need of snippet that can handle the flickr Api. I found http://phpflickr.com/ that does exactly that only since i do not know how to create a snippet nor do i understand PHP, i’m wondering if anyone has something up and running inside MODX?
      • 29839 ☆ A M B ☆
      • 66 Posts
      Another script that i would like to see running inside modx
      http://code.google.com/p/flogr/

      Any help is highly appreciated
        • 33968
        • 863 Posts
        Hi, I have phpFlickr working on a test site but the code is not ready to release as an extra.

        What features do you need exactly? I’ll let you know if it will work without needing any changes smiley
          • 29839 ☆ A M B ☆
          • 66 Posts
          I would need to be able to grab a flickr set, or tag and output it to a template so that i can have some jquery code display it.
            • 33968
            • 863 Posts
            Ok this should do it - it's by no means perfected or thoroughly tested, so comes with no warranty whatsoever!!
            Sorry, no one-click install either wink


            Installation
            To install:

            • first create a new folder for the snippet at:  assets/snippets/phpFlickr/
            • download the attached file (contains snippet and phpFlickr 1.3.2) and unzip in that folder
            • in MODx manager, create a new snippet named phpFlickr and paste in the contents of 'snippet.phpflickr.php'


            Configuration

            You'll need to configure the snippet to work with your API key

            • Get an API key from flickr. Choose 'non-commercial' unless you intend to make a profit from your use of the API. Note down your API key, and also your 'secret'. Also note down your Flickr user ID.
              Note: if your gallery on Flickr is private but you want to include those images on your site for public use, use phpFlickr's authentication tool. Follow the steps provided.

            • Go back into the 'phpFlickr' snippet, and insert the codes into the following fields:
              $api_key    = '................................';
              $secret      = '................';
              $assets_path = '/path/to/modx/assets/folder/';
              $user_id    = $modx->getOption('user_id',$scriptProperties,'........@...');

              $assets_path is the full path to the /assets folder in your modx root.


            Snippet usage

            I'd originally set this up to allow different display modes: individual 'photo', 'sets', or 'search'. There are some basic (but admittedly ambiguous) explanations for how to use the snippet (including further configuration options) at the beginning of the snippet code.

            To grab a set:
            [[!phpFlickr?
               &ids=`xxxxxxxxxxxxxxxx`  <-- comma separated ids of sets you want to display
               &mode=`set`
               &thumbSize=`square`      <-- size of thumbnail to be displayed (small, medium, square, thumbnail)
               &photoSize=`medium`      <-- size of larger image to be loaded by link (‘small’, ‘medium’, ‘medium_640′, ‘large’ , 'original')
               ]]
            


            To search by tags:
            [[!phpFlickr?
               &mode=`search`
               &search=`tags=tag1,tag2` <-- comma delimited list of tags
               &thumbSize=`square`      <-- size of thumbnail to be displayed (small, medium, square, thumbnail)
               &photoSize=`medium`      <-- size of larger image to be loaded by link (‘small’, ‘medium’, ‘medium_640′, ‘large’ , 'original')
               ]]
            


            NOTE: The API can be slow at times so I strongly recommend caching the snippet once you are happy it is working correctly.


            Templating:

            Output can be templated in a similar way to Wayfinder. Create two chunks which will be used as templates:

            flickr_wrap 
            (similar to Wayfinder 'outerTpl')
            <h2>[[+f.title]]</h2>
            <p>[[+f.description]]</p>
            <ul class="gallery">
                [[+f.photos]]
            </ul>
            


            flickr_tpl
            (similar to rowTpl)
            <li>
                <a href="[[+f.photo]]" class="colorbox" title="[[+f.title]]"><img src="[[+f.thumb]]" /></a>
                <p><strong>[[+f.title]]</strong></p>
                <p>[[+f.description]]</p>
            </li>



            I've used this successfully with the colorbox plugin. You should be able to customise it fairly easily to work with any other.

            Let me know if you get stuck or need help customising your output. Also, if this proves to be useful I'll consider finishing it properly, documenting, and releasing as an official package.

            Cheers [ed. note: okyanet last edited this post 15 years, 1 month ago.]
              • 33968
              • 863 Posts
              Did that work? I actually spent a fair bit of time cleaning the snippet up and writing that guide; would have been nice to at least get some feedback!
                • Posts
                Hi Lucas,

                Any chance you could reupload that file? Just with the new forums I think it's gone walk-about and I'd love the opportunity to try it because I think this is exactly what I need. I'm struggling to get phpFlickr to work with ModX.
                  • 33968
                  • 863 Posts
                  Hi there, I've just re-uploaded the file above - it should work now.

                  It is kinda rough but I hope you find it useful...
                    • Posts
                    Hi, this looks good.

                    Would you mind if I used it commercially? No worries if not!
                      • 33968
                      • 863 Posts
                      Please go ahead, you're welcome to use it however you wish. It was intended to be open source as was the phpFlickr class it uses. Just take care to respect Flickr's copyright conditions and you'll be fine.

                      Note that I haven't tested the snippet thoroughly so let me know if you have any issues with it.