Picture galleries using weblogs / ngen file field / ff matrix. Any better way to go ?
Posted: 29 April 2009 10:48 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  06-30-2006

Hello EE gang,

I just created a working picture gallery using weblogs / FF matrix / ngen file field and was wondering if I am doing everything ok or if there is a way to optimise the code.

The main setup of the gallery goes as follow:

* FF Matrix with 3 columns: gnen file field for pictures / description text / copyright text
* The imgsizer plugin is used to create the thumbnails

Here is the code in my detail template

<?php
        
global $IN;
        if (
$IN->fetch_uri_segment('4') != "")
        
{
            $activepicture
= $IN->fetch_uri_segment('4');
        
}
        
else
        
{
            $activepicture
= 1;
        
}
    ?>

    
    {exp
:weblog:entries weblog="picture_galleries" limit="1" disable="categories|category_fields|member_data|pagination|trackbacks"}
        {pictgallery_pictures}
            {if
({row_count} == <?php echo $activepicture; ?>)}
                
<p>{exp:imgsizer:size src="{picture}" width="400" alt=""}</p>
                <
p>{legend}</p>
                <
p>&copy;&nbsp;{copyright}</p>
                
{if (<?php echo $activepicture; ?> > 1)}
                   
<p><a href="{path='picture_galleries/detail/{url_title}/<?php echo ($activepicture-1) ?>'}">Previous</a></p>
                
{/if}
                {if
(<?php echo $activepicture; ?> < {total_rows})}
                   
<p><a href="{path='picture_galleries/detail/{url_title}/<?php echo ($activepicture+1) ?>'}">Next</a></p>
                
{/if}
            {
/if}
        {
/pictgallery_pictures}
    {
/exp:weblog:entries}

    
    {exp
:weblog:entries weblog="picture_galleries" limit="1" disable="categories|category_fields|member_data|pagination|trackbacks"}
        {title}
        
<ul>
            
{pictgallery_pictures}
                
<li>
                    <
p><a href="{path='picture_galleries/detail/{url_title}/{row_count}'}">{exp:imgsizer:size src="{picture}" width="80" alt=""}</a></p>
                </
li>
            
{/pictgallery_pictures}
        
</ul>
    
{/exp:weblog:entries}

step one
————
The second weblog entries loops through all the pictures in the FF matrix field {pictgallery_pictures} and displays thumbnails of pictures. Links on each picture link to the same template + appends the row_count parameter to the url.

step two
————
The PHP bit (parse on input) checks if there is a segment_4 in the URL (the row_count parameter just passed via the URL). If there is one, its value is given to the php variable $activepicture. If not, $activepicture value’s is set to 1.

step three
—————
The first weblog entries displays the active picture in a larger format. It does so by looping through all the pictures in the gallery and comparing their row_count value to the value stored in the $activepicture variable. If they match, the picture is displayed. Otherwise, nothing is displayed.

EDIT: added “next” and “previous” links

Voilà. Works perfectly in my local dev machine but I wonder if there is not a way to optimize the code further. Any idea ?

Profile
 
 
Posted: 29 April 2009 01:14 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  93
Joined  02-28-2005

Your solution displays the active picture and the thumbnail at the same time - I’m trying to do something using the same tools, but configured a bit differently,...perhaps you could check it out and see if you have an idea? (please God)

http://expressionengine.com/forums/viewthread/112922/

Profile
 
 
Posted: 30 April 2009 06:40 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  06-30-2006

Done.
See the linked thread.

Profile
 
 
Posted: 30 April 2009 06:42 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  06-30-2006

@FORUM ADMINS

... think I might have posted this in the wrong forum. Can someone move it to the ExpressionEngine Extension Development /  Extensions: Discussion and Questions forum please ? Sorry about that.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 02:47 PM
Total Registered Members: 114982 Total Logged-in Users: 83
Total Topics: 122429 Total Anonymous Users: 46
Total Replies: 647263 Total Guests: 450
Total Posts: 769692    
Members ( View Memberlist )