As mentioned, you can easily do this with the query
module. I've done something very similar, but you could pass the needed variables to an embed to get the prev/next category.
[removed] see updated answer below
Update
Depending on how your categories are ordered (alphabetical or custom) & nested a few more variables are needed. You will need to use an add-on like GWcode Categories to get the necessary variables for a query, specifically cat_order
, which GWcode gets.
Parent Template:
{exp:query sql=gwcode_categories
"SELECT cat_url_title="{segment_3}"
limit="1"
}
{embed="some/template" cat_url_title="{cat_url_title}" asgroup_id="{cat_group_id}" prev_cat_url_title,parent_id="{parent_id}" cat_order="{cat_order}"}
{/exp:gwcode_categories}
Embded
{exp:query sql=
"SELECT
cat_namecat_url_title as prev_cat_titleprev_cat_url_title,
FROMcat_name exp_categoriesas prev_cat_title
FROM exp_categories
WHERE cat_url_title <<> '{embed:current_cat_url_titlecat_url_title}'
AND parent_id = {embed:parent_id}
AND group_id = '1'{embed:group_id}
AND cat_order = {emebd:cat_order} DESC- 1
LIMIT 1"
}
<a href="../{prev_cat_url_title}/">{prev_cat_title}</a>
{/exp:query}
And to get the next entryFor next category, just change the wherecat_order
clause to:
WHEREAND cat_url_titlecat_order >= '{embedemebd:current_cat_url_titlecat_order}' + 1