the Forum

Expression Engine pager for PREV and NEXT alphabetically

Posted on March 10, 2013 by Michael Rosario
Total Posts: 33  |  Join date: 03-12-11

In expression engine, you can go to next and previous entries using the following tags:
{exp:channel:next_entry}
    
<p>Next entry: <a href="{path='site/comments'}">{title}</a></p>
{/exp:channel:next_entry}

{exp
:channel:prev_entry}
    
<p>Previous entry: <a href="{path='site/comments'}">{title}</a></p>
{/exp:channel:prev_entry} 
However this is sorted by entry_date, If you wanted it sorted alphabetically, this is another approach thanks to the post from: http://www.ngenworks.com/blog/expressionengine_and_previous_next
{exp:query sql="SELECT url_title, title FROM exp_channel_titles WHERE url_title < '{embed:uri}' AND channel_id = '6' AND exp_channel_titles.status = 'open' ORDER BY url_title DESC LIMIT 1"}<a href="/work/{url_title}" title="{title}">{title}</a>{/exp:query}

{exp
:query sql="SELECT url_title, title FROM exp_channel_titles WHERE url_title > '{embed:uri}' AND channel_id = '6' AND exp_channel_titles.status = 'open' ORDER BY url_title ASC LIMIT 1"}<a href="/work/{url_title}" title="{title}">{title}</a>{/exp:query} 

Tags: There are no tags for this entry.

1 answer, add yours below

Posted on on March 28, 2013 at 5:04am
by James Kepper

Thanks for this, was looking for this code and struggling to find it smile

 
add your answers here
comments powered by Disqus