A UDT for the album module to show a different album per page
Posted: Fri May 07, 2010 11:07 am
Tried to log in to the documentation, was not working and no sign up so I thought I would share this tag here.
I wanted a different album to appear on each page but the module only allows you to supply a list of IDs which is not exactly an elegant solution to the problem. I just created a UDT to look up the id of an album from the page alias.
To make this work your page alias would have to be like: 'gallery-page' and your album name would be 'Gallery Page'
Use this in your template
To call the UDT called gallery_gen
I wanted a different album to appear on each page but the module only allows you to supply a list of IDs which is not exactly an elegant solution to the problem. I just created a UDT to look up the id of an album from the page alias.
To make this work your page alias would have to be like: 'gallery-page' and your album name would be 'Gallery Page'
Use this in your template
Code: Select all
{gallery_gen pagetitle=$page_alias}
{if $g_id != 'false'}
{cms_module module='album' albums="$g_id"}
{/if}
Code: Select all
global $gCms;
if( !isset($gCms) ) exit;
$db = &$gCms->GetDb();
$pagetitle = ucwords ( str_replace ('-', ' ', $params['pagetitle']) );
$query = 'SELECT album_id FROM cms_module_album_albums WHERE album_name = ? LIMIT 1';
$galleryId = $db->Execute($query, array($pagetitle));
if ($galleryId->RecordCount() == 1) {
$row = $galleryId->FetchRow();
$smarty->assign('g_id', $row['album_id']);
return true;
} else {
$smarty->assign('g_id', 'false');
return false;
}