Zen Cart is great an all but it really doesn’t do image galleries very well. There are some plugins available but to be honest the admin interface is always a bit erm “clonky” in my opinion. Why not use Flickr to serve up your glorious pictures as a gallery?
Here’s my attempt at getting it to work inspired by work done by Dan Coulter at the http://phpflickr.com/ project
(Please note: this has only been tested in Zen Cart 1.3.h – I’m sure with a bit of tinkering it could be made to work with 1.5, but I dont have the time/inclination)
1) Create a Flickr account
2) Upload your pictures into groups called “Sets” – giving each a title & description. These will be pulled into your Zen Cart
3) Create an EZ page called “Gallery”
4) In the tpl_page_default.php for your theme (as always ensure you override the default) add the following block of code:
<?php if($var_pageDetails->fields['pages_title']=="Gallery"){
// check if there is a query string 'set' if($_GET['set']!=""){ //if there is a query string find out what pos it is in the photosets array $setName=$_GET['set'];
$pos=array_search($setName,$photoSetsNames);
echo "<h2>".$setName."</h2>"; echo "<p>".$photoSetsDescriptions[$pos]."<br/></p>"; echo $photoSetsPhotos[$pos]; //print_r($photoSetsDescriptions);
}else{ // if no query string then display list of all sets echo "<ul class=\"galThumbs\">";
foreach($photoSetsNames as $photoset){ $pos=array_search($photoset,$photoSetsNames); ?> <li><a href="gallery/?set=<?=$photoset?>"> <p><?=$photoset?></p> <? echo $photoSetsThumbs[$pos];?> </a></li> <? } echo "</ul>"; }
} ?>
5) Upload the two attached files phpFlickr.php and phpFlickrGetSets.php to your “includes\modules” folder phpFlickrGetSets.zip
6) Change the lines indicated in your phpFlickrGetSets.php to be your Flickr App id and the absolute path to your new folder flickr_cache (Note: You absolutely must enable caching otherwise the lookups to Flickr can slow your site down horribly! Plus db caching I found to be woefully slow so stick to file system caching) And your Flickr User Name
(Get your Flickr App Id here: http://www.flickr.com/services/apps/create/apply)
7) Make sure you have created a folder called flickr_cache & set permissions to 755
8) Include your two new modules in the tpl_header.php file like so:
/** * load the module for getting the Flickr data */
require(DIR_WS_MODULES . zen_get_module_directory('phpFlickrGetSets.php'));
I’m putting it in the site header as I want to dynamically get the list of set names to use in the site menu. If you wanted it only on the gallery page then you could just add it to your tpl_page_template.php along with the other code above
And Bob’s your uncle:
See it working here: www.dorisdesigns.co.uk
As always any comments feedback appreciated!
UPDATE: May 2014
Please not the Flickr API is going SSL from June 2014 – so you will need to edit the paths in phpFlickr.php to use https:// rather than http://
More info can be found here: http://code.flickr.net/2014/04/30/flickr-api-going-ssl-only-on-june-27th-2014/
Tony Bateman says
Doesn’t work, at least not on zen cart 1.5. Wish I had chosen an older version now as finding a gallery compatible with 1.5 is a nightmare!
Adam says
Can you tell me if you got this to work on ZenCart v1.51 ?