Album pagination in News detail template + ugly url

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
Peciura

Album pagination in News detail template + ugly url

Post by Peciura »

Lets say you have article and one or more albums related to it. You can to put comma separated album id list to News extra field (e.g. "1,2,68") and call album module like this in News detail template

Code: Select all

#
{if !empty($entry->extra)}
{cms_module module='Album' albums=$entry->extra number='15'}
{/if}
Though usually there are more pictures in albums and following Album pages do not stay inside News article any more. To solve this you can display 15 random images  or modify album template to keep pagination in the article. This example is for LightBox template but it is easy to adjust any other template.
{* Include JS files. You can move this to the head of your page template if you want *}






{if $pictureid !=0}

{* Big Picture *}

{$picture->name}

{$picture->comment}


{if $link.picture.previous}< Previous{/if}
( Picture {$picturenumber}/{$picturecount} )
{if $link.picture.next}Next >{/if}

picture}" alt="{$picture->name|escape:'html'} - {$picture->comment|escape:'html'}" onload="SMR_resize(this, {$max_image_size});" title="{$picture->name|escape:'html'}  - {$picture->comment|escape:'html'}" />

{/if}

{if !$album}
{assign var='album_base_link' value=$albums[0]->link}
{else}
{assign var='album_base_link' value=$link.page.first}
{/if}

{assign var='album_link_trim' value=$album_base_link|regex_replace:'/\&.*/':''}
{assign var='temp' value=$album_base_link|regex_replace:'/.*mact=/':''|regex_replace:'/\&.*/':''}
{assign var='album_params' value=','|explode:$temp}
{assign var='album_parent_module_url' value=$smarty.server.REQUEST_URI|regex_replace:"/\&$album_params[1][^\&]*/":''|escape}
{assign var='album_link_rtrim' value=$album_base_link|regex_replace:"/^.*$album_params[1][^\&]*/":''}

{assign var='album_control_name' value='album_control'}

{* Album List *}
{if !$album}

{foreach from=$albums item=album}

link|replace:$album_link_rtrim:''|replace:$album_link_trim:$album_parent_module_url}#{$album_control_name}" title="{$album->name|escape:'html'}">
thumbnail}" alt="{$album->name|escape:'html'}" title="{$album->name|escape:'html'} - {$album->comment|escape:'html'}"{$album->autothumbnailsize} />

{$album->name}

({$album->picturecount} images)

{$album->comment}

{/foreach}


{else}

{* Photo List *}
{$album->name}

{$album->comment}

Click on a thumbnail to view a larger image. Click on the close button to close it. {if $returnlink}Return to the album index page{/if}

{if $pagecount>1}


<< 
{if $link.page.previous}< {/if}
page {$pagenumber}/{$pagecount}
{if $link.page.next} >{/if}
 >>

{/if}


{foreach from=$pictures item=picturesrow}
    {foreach from=$picturesrow item=onepicture}
    picture}" rel="lightbox[{$album->name|escape:'html'}]" title="{$onepicture->name|escape:'html'} {if ($onepicture->comment != "")}- {$onepicture->comment|escape:'html'}{/if}"> thumbnail}" alt="{$onepicture->name|escape:'html'} - {$onepicture->comment|escape:'html'}" title="{$onepicture->name|escape:'html'} - {$onepicture->comment|escape:'html'}"{$onepicture->autothumbnailsize} />
   

      {if ($onepicture->number==$picturenumber and !$picture)}{assign var=picture value=$onepicture}{/if}
    {/foreach}
{/foreach}


{if $picturecount==0}No image{/if}
{/if}

{if $picture->id>0}
{/if}
Post Reply

Return to “Tips and Tricks”