exp:low_reorder:next_entry - retrieving category_id on single entry templates without using the category in a URL segment
Using exp:low_reorder:next_entry on sets using "show entries per single category", how can I get a category_id within a single entry template where I do not use categories in the URL for the single entry template?
For listing entries by category, I use a URL structure like this:
topics/list/category/{cat_url_title}
Then those listed entries link to a template to display the single entry:
topics/detail/{entry_url_title}
Each entry is assigned to a "last child" category (and auto assigned to that category's parent). My sets are sorted by the last child categories and those sets are all I am interested in using to display the next/prev entry.
When I display an entry, I would like the template to be able to pluck out the last child category it is assigned to and provide a next/prev entry link within that last child category.
One suggestion might be to use the category url title as a segment of the URL, and use Seg2Cat to convert it to the category_id. This would require installing an additional addon, modifying my URL structure, and editing multiple templates to reflect the new URL structure. In addition, I would not be able to include that category segment in my URLs in search results.
Is there an easier or better way to do what I want?
I use gwcode_categories elsewhere in my templates, so I have been experimenting with that. No luck so far.
Replies
Low 20 Nov 2013 07:27
Well, since an entry can belong to multiple Low Reorder sets, you need to feed the prev/next entry tags both the set name/id and category id. Also, an entry can belong to multiple categories, so it's extra important to pass through a valid category ID here, too. If you're not using categories in your URLs, you'll need to use the {categories}{/categories} var pair to generate the ID, and nest the prev/next tags inside the Entries tag.
You might need to exclude the parent IDs from it by using the show parameter, which you'll probably need to hard-code.
Jon 20 Nov 2013 20:27
Thanks for your reply.
I had thought of nesting the prev/next_entry tags inside of the Entries tag pair to make use of the categories pair, but I thought the prev/next_entry tags didn't work properly inside of the Entries tags.
I tried your suggestion with this code:
Next/Prev links are built, but they do not link to the correct entry. Instead they link to the entry currently being displayed on the same page.
Low 20 Nov 2013 20:36
Use the prefix parameter to avoid variable name conflicts: http://gotolow.com/addons/low-reorder...
Jon 20 Nov 2013 20:51
Should I use the prefix parameter on the exp:low_reorder:next_entry tags or the exp:channel:entries tag?
I added a prefix="loworder" to the next_entry tag, and then used {loworder_title} inside the tags. It did not parse it.
Low 20 Nov 2013 21:04
The prefix parameter should include the entire prefix, including the (optional) underscore. So use something like:
Jon 20 Nov 2013 21:33
Thanks, that seemed to do the trick!
How does the prefix affect the {if no_results} conditional?
Low 20 Nov 2013 22:24
It does not. But you should be able to use {if low_reorder_no_results} too.
Jon 21 Nov 2013 01:08
Thanks for your support.