entry linking plugin
Posted: 25 March 2005 05:04 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  836
Joined  04-17-2002

I’d done a plugin to remove the in-category restriction on entry linking in the gallery module. I’m using it at the moment in my gallery archive.

Just today I set about adding a parameter. While I was doing this, I noticed that the code in the gallery module for entry linking has been changed with EE 1.2.1. So, I updated my plugin and it is working ok EXCEPT the next link actually goes to the previous entry and the previous link actually goes to the next entry (I expect the entries to be ordered by ascending entry ids).

Is there some new undocumented parameter that I’m missing related to the order of entries? I’ve noted 2 variables in the new code that weren’t there before. Namely $cycle and $order, but it isn’t clear to me how they are utilised, or even if they are parameters at all. I’m guessing the $cycle variable is to force looping, because my markI plugin didn’t have this feature whereas the new one does. But what is the order variable and how can I harness it? BTW: it would be good to be able to choose if I want looping or not.

Note I’ve also tried the native entry linking tags just to check, and the behaviour is the same. The order is correct, only reversed.

 Signature 

antipodean.org | uptheduff.org

Profile
 
 
Posted: 25 March 2005 10:30 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRank
Total Posts:  2541
Joined  12-21-2001

Entry links are ordered by date, not ID number, so they appear in chronological order.  Before 1.2.1 the links were not ordering correctly.  They were backwards.  The change was actually a bug fix.

The $order variable is not a publicly accessible variable.  Since the next/previous links share a common function to builds the query, the $order is set based on which link is being generated.  If the “next” link is being shown the query is sorted in descending order so that the next date is shown, whereas the “previous” link uses ascending order so that the earlier date is shown.

 Signature 
Profile
MSG
 
 
Posted: 25 March 2005 03:57 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  836
Joined  04-17-2002

Thanks Rick, but I’m even more confused now. entry_id should ascend as the dates of entry ascend unless I specifically alter the dates, right?

I set up this test gallery (thumbs displayed by a single category-London, no styles, sorry about that smile The thumbs are shown in chronological order. The power station building (id 8) is the first I posted in this category, the horse statue (id 37) is the latest (I posted it just the other day). So nextand prev links should follow the same order,right? I use the following code to display the nex/prev links.

{exp:gallery:prev_entry gallery=“photos”}
<a href=”{path=photos/test}” title=“previous”><prev</a>
{/exp:gallery:prev_entry}

{exp:gallery:next_entry gallery=“photos”}
<a href=”{path=photos/test}” title=“next”>next></a>
{/exp:gallery:next_entry}

You’ll see that the links go in the wrong direction. The next link isto the previous image, the prev link is to the next image.

Compare that to the link I gave in the first post, where I use the plugin I made from the older 1.2 code. The links point in the right direction.

Like I said, I’m completely confused. Sorry if there is something obvious I’m missing here.

 Signature 

antipodean.org | uptheduff.org

Profile
 
 
Posted: 26 March 2005 11:10 AM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRankRankRankRank
Total Posts:  2541
Joined  12-21-2001

Interesting.  It does appear to be reversed.  I just confirmed this behavior.  I’m very surprised no one has notice this before. 

Do me a favor and make the following change.  Let me know if it makes it cycle correctly.

Open: modules/gallery/mod.gallery.php

At line 1820 change this:


if ($cycle == '')
    
{
        
if ($type == 'next')    
            
$sql .= " AND t1.entry_date < t2.entry_date ";
        else
            
$sql .= " AND t1.entry_date > t2.entry_date ";
    
}


To this:

if ($cycle == '')
    
{
        
if ($type == 'next')    
            
$sql .= " AND t1.entry_date > t2.entry_date ";
        else
            
$sql .= " AND t1.entry_date < t2.entry_date ";
    
}



Then at line 1847, change this:

if ($cycle == '')
        
$order = ($type == 'next') ? 'desc' : 'asc';
    else
        
$order = ($type == 'next') ? 'asc' : 'desc';


To this:

if ($cycle == '')
        
$order = ($type == 'next') ? 'asc' : 'desc';
    else
        
$order = ($type == 'next') ? 'desc' : 'asc';

 Signature 
Profile
MSG
 
 
Posted: 26 March 2005 11:43 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  836
Joined  04-17-2002

Yep. That does the job. The links now appear correctly in both directions and looping is ok too.

Thanks Rick. Should I continue with my plugin using this?

 Signature 

antipodean.org | uptheduff.org

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 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64978 Total Logged-in Users: 24
Total Topics: 82015 Total Anonymous Users: 18
Total Replies: 440812 Total Guests: 194
Total Posts: 522827    
Members ( View Memberlist )