The code you currently have (after fixing the arrowsParams
typo) will only work on entries that happen to have the very first category in the Seasons category group selected, because this title
parameter is actually not getting any value right now:
.title(entry.season.title)
Why? Because entry.season
is not going to return the first category you have selected in your Season categories field; it’s going to return an ElementCriteriaModel that is prepped to return the category(s) selected in your Season categories field, once one of its output functions have been called.
Since entry.season
is an ElementCriteriaModel, entry.season.title
is actually just going to return its current title
parameter value (which is null
by default). So this:
{% set category = craft.categories.group('seasons').title(entry.season.title).first() %}
is really the same as this:
{% set category = craft.categories.group('seasons').title(null).first() %}
which is the same as not including the parameter at all, so it’s also the same as this:
{% set category = craft.categories.group('seasons').first() %}
So category
is always going to be set to the first category in the group, and arrowsParams
is going to be set to all of the Blog entries that are related to that first category.
If the entry you’re viewing doesn’t have that first category selected, then its getNext() and getPrev() functions won’t return anything. (If they can’t determine where the current entry fits into the parameters that were passed in, they can’t determine what the next and previous entries would be.)
Anyway, to fix this, you would need to put a .first()
call inside that title
param when setting the current category:
{% set category = craft.categories.group('seasons').title(entry.season.first().title).first() %}
But here’s the thing: entry.season.first()
is already the category you’re trying to get. So there’s no point in fetching it through a second craft.categories
query in the first place. This will do just fine:
{% set category = entry.season.first() %}
arrowsParams
, shanti? – carlcs Aug 23 '14 at 9:22