Add "previous resource" and "next resource" links?

Add "previous resource" and "next resource" links?

Postby cactusman on Fri Aug 15, 2008 10:13 am

When you see one of the resource, you need to come back in the thumbnails page to open the next resource.
I was thinking that it might be a nice feature to have a "previous resource" and "next resource" links to see the resources one after each other without to have to go to the thumbnails page everytime !
Does is seems to be a good idea?

I found that in the file class/gallery/dao/galleryresources.class.php :

Code: Select all
    * given a resource id, tries to find the next one in the sequence
    *
    * @param resource A GalleryResource object that represents the resource whose next
    * object we'd like to load
    * @return Returns a GalleryResource object representing the next resource, or false
    * if there was no next resource
    */     
    function getNextResource( $resource )
    {     
       $prefix = $this->getPrefix();
       $albumId = $resource->getAlbumId();
       $date = $resource->getDate();
       $id = $resource->getId();
       $query = "SELECT id, owner_id, album_id, description,
            date, flags, resource_type, file_path, file_name,
            metadata, thumbnail_format, properties, file_size
            FROM {$prefix}gallery_resources
       WHERE album_id = '$albumId' AND date >= '$date' AND id > $id
       ORDER BY date ASC,id ASC LIMIT 1";

       $result = $this->Execute( $query );
             
       if( !$result )
       return false;
       if( $result->RecordCount() == 0 ){
            $result->Close();
       return false;
            }
               
       $row = $result->FetchRow();
            $result->Close();
       $resource = $this->mapRow( $row );
         
       $this->_cache->setData( $resource->getId(), CACHE_RESOURCES, $resource );
       $this->_cache->setData( $resource->getFileName(), CACHE_RESOURCES_BY_NAME, $resource );         
             
       return $resource;
       }



Is it possible to use that?
I have to confess I don't know anything about smarties except it's some kind of chocolate candies :lol:
cactusman
 
Posts: 73
Joined: Sun Feb 25, 2007 4:55 am
Location: Japan
LifeType Version: 1.2.8

Re: Add "previous resource" and "next resource" links?

Postby jondaley on Fri Aug 15, 2008 10:47 am

My template uses:
Code: Select all
   {if $album->getShowAlbum()}
     <p>
       {if $prevresource}<a href="{$url->resourceLink($prevresource)}">&laquo;</a> | {/if}
       <a href="{$url->albumLink($album)}">{$locale->tr("back")}</a>
       {if $nextresource}| <a href="{$url->resourceLink($nextresource)}">&raquo;</a>{/if}
     </p>
   {/if}


http://jon.limedaley.com/plog/resource/ ... esults.jpg
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: Add "previous resource" and "next resource" links?

Postby cactusman on Fri Aug 15, 2008 11:45 am

What can i say... just thank you again !
Maybe it would be a good ides to implement that in the default template?
cactusman
 
Posts: 73
Joined: Sun Feb 25, 2007 4:55 am
Location: Japan
LifeType Version: 1.2.8


Return to Requests and Suggestions