The weblog:entries tag enables you to link to next/previous entry based on entry creation date.
But what if you want to use sorting order based on other parameter, and still have next/prev links?
Here’s the add-on that will help you!
Using Entry Linking plugin, you can sort your weblog entries based on any - standard or custom - field you want and make your next/prev links follow that order!
Example usage:
{exp:entry_linking entry_id="1" link="next" weblog="my_weblog"
orderby="my_custom_field" sort="ASC" status="open"
category="1|2"
mode="short"}
<a href="{path=site/{link_url_title}}">{link_title}</a>
{/exp:entry_linking}
entry_id is the required parameter.
Possible values for link are ‘next’ and ‘prev’. Defaults to ‘next’.
You can use your custom field names for orderby parameter (defaults to entry_date).
All returned variables will be prefixed with ‘link_’
You can use the plugin in any part of your template.
The current version of plugin supports only ‘short’ mode (i.e. return only entry_id, title and url_title). I don’t think you need more for pagination
But if you do - please let me know and I’ll include ‘full’ mode in future releases.
Download entry_linking plugin - NEW v.1.2
Posted by runner at 09:37 PM.
Filed under:
Extending EE •
Plugins •
(14) Comments •
Permalink
Thanks! I was just looking for something like this, but couldn’t find anything even remotely useful. Works just great and is flexible enough!
One suggestion though: maybe the first/last links could be hidden if viewing the first/last entry? Now the links are looping the whole weblog. Just an idea
Posted by .(JavaScript must be enabled to view this email address) on 04/26 at 05:58 PM
Jani, you can achieve this by replacing
if ($link=='next')
{
$pos++;
if ($pos==count($ids)) $pos=0;
} else {
$pos--;
if ($pos==-1) $pos=count($ids)-1;
}
with
if ($link=='next')
{
$pos++;
if ($pos==count($ids)) return $TMPL->no_results;
} else {
$pos--;
if ($pos==-1) return $TMPL->no_results;
}
Posted by .(JavaScript must be enabled to view this email address) on 04/26 at 07:55 PM
great plugin, thank you.
It would be awesome if you could limit the next and prev links to a specific category as well.
Would that be difficult to accomplish?
Posted by .(JavaScript must be enabled to view this email address) on 06/03 at 04:01 AM
James, that sounds like a good feature. I think I’ll code that and release in a week or two.
Posted by .(JavaScript must be enabled to view this email address) on 06/03 at 01:39 PM
I second the request to limit to specific categories. That would be awesome.
Posted by .(JavaScript must be enabled to view this email address) on 06/03 at 09:00 PM
Nice plugin. Thanks.
Can you let me know when it’s been updated to ‘limit to specific categories”. That would be perfect for a project I’m working on
Posted by .(JavaScript must be enabled to view this email address) on 06/11 at 11:50 AM
The ‘limit to specific categories’ feature has been implemented. Use it by passing parameter catagory=“1”. You can specify multiple categories by separating them with a pipe.
Please note that I did not test myself this yet
so if you encounter any bugs, report them here.
The donwload link is in the post above.
Posted by .(JavaScript must be enabled to view this email address) on 06/11 at 05:38 PM
Hey,
Thanks for the update.
Have given it a go but I can’t get it to limit to the category I’m on. The ‘category’ tag doesn’t seem to have any effect. Has any one else had any issues?
Cheers
Posted by .(JavaScript must be enabled to view this email address) on 06/12 at 09:18 AM
Steve, do you use ‘category’ tag or parameter? You should use parameter (like in example in docs).
If you are willing, I can have a look at your installation and quickly fix everything.
Posted by .(JavaScript must be enabled to view this email address) on 06/12 at 09:52 AM
Soon after - bugfix version (1.2). Please download and install this one.
Posted by .(JavaScript must be enabled to view this email address) on 06/12 at 11:22 AM
Great plugin!
I second the request to be able to turn off the looping between the last-to-first and first-to-
last of the results.
Could you provide any quick fixes to this?
Posted by .(JavaScript must be enabled to view this email address) on 06/21 at 09:05 PM
Eek, I just noticed that you had followed up already on this topic. I was thrown off by the order of the comments.
The fix you posted worked really great! Thanks again for an awesome plugin.
Posted by .(JavaScript must be enabled to view this email address) on 06/21 at 09:07 PM
You’re welcome, Mason
Posted by .(JavaScript must be enabled to view this email address) on 06/22 at 08:00 AM
Very useful article.Surely will visit your blog again later,thanks for sharing.
Posted by .(JavaScript must be enabled to view this email address) on 09/02 at 06:29 PM