Skip to content
This repository was archived by the owner on Sep 27, 2022. It is now read-only.

SimpleFlickr Example Usage

imageaid edited this page Jan 1, 2011 · 1 revision

##Example Usage## Once configured, the plugin is quite easy to use. In the desired controller(s), configure the SimpleFlickr plugin* and call the desired method.

<cfscript>
// this is an excerpt from a controller called Destinations (taken from a mountain guides web site)
function show(){
    destination = model("Destination").findOne(where="link_name='#lcase(link_name)#'");
    // **This is a temporary hack ... see note at end of section for details
    $setSimpleFlickrConfig(argumentCollection=get("flickr")); // configure the SimpleFlickr plugin with the correct access data
    try{
        // call the plugin's getFlickrPhotoSetPhotos to grab the photos from the Flickr API call
        slideshow = getFlickrPhotoSetPhotos(photosetID = destination.flickr_set_id);
        // or, if you wanted to get your photos by a tag or tags, you could try one of the following
        slideshow = getFlickrPhotosByTags(tags = "puppies,dogs,beer",tagMode="any");
        // or ...
        slideshow = getFlickrPhotosByTags(tags = "coldfusion,cfml",tagMode="all",userUserID=false);
    }
    catch(Any e){
        // return an empty array if we encountered any problems with the Flickr API call.
        slideshow = [];
    }
}
</cfscript>

In the relevant view(s), you could loop over the arrays and output the images with something along the lines of the following:

<cfoutput>
    <div id="slider">
        cfloop array="#arguments.slideshow#" index="photo">
        #imageTag(source=photo.url, title=photo.title)#
        </cfloop>
    </div>
</cfoutput>

*As of v0.2.5, I'm having an issue with successfully calling and executing the plugin's configuration method, $setSimpleFlickrConfig(), from the config/settings.cfm file. Even though the plugin is successfully loaded, Wheels does not see it yet. I'm still learning the ins and outs of Wheels and am sure I have something off just a tad. This will be sorted out in v0.5 so that configuration of the plugin can be run on application start/initialization.

Clone this wiki locally