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
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.]