Page 1 of 1

RSS Feed for Album module

Posted: Fri Nov 14, 2008 5:50 am
by tyman00
I was messing around with my personal site and wanted to give my family the option to subscribe to my Photo Album via RSS.

With the use of CGFeedMaker 1.0 and Album 0.9.3 I was able to put something together. It was fairly simple. I set mine up to display the last 15 uploaded images using the "recently_updated" action in Album. The feed template below calls for specific Albums but I would suppose you could call images by categories as well. I am sure any combination of parameters that you can specify for Album can be used.

Look for the smarty comments to walk you through the template.  ex: {* comment *}

Code: Select all

{* Display photos from the Album Module in a RSS Feed *}
{* This template displays the most recently added photos *}
{* Specific albums can be specified *} 

<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>{$feed.title}</title>
    {if isset($feed.link) && !empty($feed.link)}<link>{$feed.link}</link>{/if}
    {if isset($feed.description) && !empty($feed.description)}<description>{$feed.description}</description>{/if}
    {if isset($feed.copyright) && !empty($feed.copyright)}<copyright>{$feed.copyright}</copyright>{/if}
    {if isset($generator)}<generator>{$generator}</generator>{/if}
    {if isset($feed.managing_editor) && !empty($feed.managing_editor)}<managingEditor>{$feed.managing_editor}</managingEditor>{/if}
    {if isset($admin_email)}<webMaster>{$admin_email}</webMaster>{/if}
    {if isset($feed.image) && !empty($feed.image)}
      <image>
	{if isset($feed.description) && !empty($feed.description)}<description>{$feed.description}</description>{/if}
        {if isset($feed.link) && !empty($feed.link)}<link>{$feed.link}</link>{/if}
        <title>{$feed.title}</title>
        <url>{$file_location}/{$feed.image}</url>
      </image>
    {/if}
 
    {capture assign='photos'}
      {* You can limit which albums you want the feed to access. Ex: albums='1,3,4' - Remove the parameter if you want  all albums to be accessed *}
      {* Specify the number of photos you want to be displayed in your feed with number='' *}
      {* See the Album module help for more information and parameters *}
      {cms_module module='album' action='recently_updated' albums='4' number='15'}
    {/capture}    

    {foreach from=$pictures item='entry'}
    <item>
      <title>{$entry->name}</title>
      <link>{$entry->picture}</link>
      <description> 
	   <![CDATA[<a href="{$entry->picture}"<img src="{$entry->thumbnail}" alt="image" width="{$entry->thumbnailwidth}" height="{$entry->thumbnailheight}"/></a><br/>
	   {$entry->comment} {$entry->comment2} {$entry->comment3}<hr />]]>
      </description>
    </item>
    {/foreach}
  </channel>
</rss>
Here is a link to a working version: http://www.tyjobo.com/feeds/photos-sample/

Some RSS Aggregators don't like displaying the actual photo and it displays a link to the photo instead. If you view it with Konqueror, FireFox or Internet Explorer photos should be displayed.

Re: RSS Feed for Album module

Posted: Fri Nov 14, 2008 6:00 am
by JeremyBASS
Sweet!! nice tip.... :)