<p>I think you are on the right track, in that you will likely need to create a separate route for the entries when they are 'featured', so that you can configure the nav properly in the template. I can think of a few ways to do this (and I'm sure there are more).</p>

<hr>

<p>Add a custom route, adding a '/featured/' segment to the uri. Then in the entries template test for the segment, and modify the entries ('params') and the nav accordingly.</p>

<pre><code>{% set isFeatured = (craft.request.getSegment(2) == 'featured') ? true : false %}
{% if isFeatured %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.featured) %}
    {% nextUrl = siteUrl ~ '/featured/' ~ entry.getNext(params).slug %}
    {% prevUrl = siteUrl ~ '/featured/' ~ entry.getPrev(params).slug %}
{% else %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.galleries) %}
    {% nextUrl = entry.getNext(params).url %}
    {% prevUrl = entry.getPrev(params).url %}
{% endif %}
</code></pre>

<hr>

<p>Add a parameter to the uri (i.e. <code>?v=featured</code> and test for the parameter in the template. Then pass the parameter on in the navigation.</p>

<pre><code>{% set isFeatured = (craft.request.getParam('v') == 'featured') ? true : false %}
{% if isFeatured %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.featured) %}
    {% nextUrl = entry.getNext(params).url ~ '?v=featured' %}
    {% prevUrl = entry.getPrev(params).url ~ '?v=featured' %}
{% else %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.galleries) %}
    {% nextUrl = entry.getNext(params).url %}
    {% prevUrl = entry.getNext(params).url %}
{% endif %}
</code></pre>

<hr>

<p>Abstract the relationship by creating a new 'featured' entries channel, with an <code>entries</code> field that links to the actual entry. Then the 'featured' category can link to the 'featured' entries (which are subsequently linked to the real entries). The featured template can then just include the normal entry with a variable <code>isFeatured=true</code> or something.</p>

<pre><code>// In 'featured' entry template
{% include 'mychannel/_entry' with { entry: entry.myEntriesField, isFeatured: true } only %}

// In native entries template
{% if isFeatured %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.featured) %}
{% else %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.galleries) %}
{% endif %}
</code></pre>

<hr>

<p>I'm sure there are more but one those might work.</p>

CC BY-SA 3.0
2016-12-04T15:33:32.723Z
2016-12-04T15:33:32.723Z
Douglas McDonald
<p>I need some advise on the best way to achieve this.</p>

<p>I have entries within a section which could belong to category A, B, C, D. Any of these entries could also belong to a Featured category.</p>

<p>Each category has it's own page, and from an entry you can go to the next or previous entry (within that category).</p>

<p>I can't see how I can do this for the Featured entries as they also belong to another category. </p>

<p>I'm thinking I'll have to do something with the URLs so the entry knows its been clicked on from the 'Featured' category page rather than 'B' so the Previous and Next buttons stay within 'Featured'.</p>

<p>This is my Next and Previous buttons code on the entry template:</p>

<pre><code>{% set params = craft.entries.section('galleries').relatedTo(categories.galleries) %}
{% set nextEntry = entry.getNext(params) %}
{% set prevEntry = entry.getPrev(params) %}

&lt;div class="previous-next-links align-right"&gt;
    {% if prevEntry %}&lt;a href="{{ prevEntry.url }}" class="cta-link prev cta-link--back"&gt;Prev&lt;/a&gt; |{% endif %}

    {% if nextEntry %}&lt;a href="{{ nextEntry.url }}" class="cta-link next"&gt;Next&lt;/a&gt;
    {% else %}
        &lt;span class="cta-link cta-link--inactive next"&gt;Next&lt;/span&gt;
    {% endif %}
&lt;/div&gt;
</code></pre>

<categories>
Navigating through entries within a category when they belong to multiple
# Navigating through entries within a category when they belong to multiple

(Asked by: username_0 on 2016-12-01)

I need some advise on the best way to achieve this.
I have entries within a section which could belong to category A, B, C, D. Any of these entries could also belong to a Featured category.
Each category has it's own page, and from an entry you can go to the next or previous entry (within that category).
I can't see how I can do this for the Featured entries as they also belong to another category. 
I'm thinking I'll have to do something with the URLs so the entry knows its been clicked on from the 'Featured' category page rather than 'B' so the Previous and Next buttons stay within 'Featured'.
This is my Next and Previous buttons code on the entry template:
{% set params = craft.entries.section('galleries').relatedTo(categories.galleries) %}
{% set nextEntry = entry.getNext(params) %}
{% set prevEntry = entry.getPrev(params) %}


    {% if prevEntry %}Prev |{% endif %}

    {% if nextEntry %}Next
    {% else %}
        Next
    {% endif %}

**Tags:** categories


---

## 1 answers

### Answer by username_1 on 2016-12-04. Score: 2 | Accepted answer

I think you are on the right track, in that you will likely need to create a separate route for the entries when they are 'featured', so that you can configure the nav properly in the template. I can think of a few ways to do this (and I'm sure there are more).

Add a custom route, adding a '/featured/' segment to the uri. Then in the entries template test for the segment, and modify the entries ('params') and the nav accordingly.
{% set isFeatured = (craft.request.getSegment(2) == 'featured') ? true : false %}
{% if isFeatured %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.featured) %}
    {% nextUrl = siteUrl ~ '/featured/' ~ entry.getNext(params).slug %}
    {% prevUrl = siteUrl ~ '/featured/' ~ entry.getPrev(params).slug %}
{% else %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.galleries) %}
    {% nextUrl = entry.getNext(params).url %}
    {% prevUrl = entry.getPrev(params).url %}
{% endif %}


Add a parameter to the uri (i.e. ?v=featured and test for the parameter in the template. Then pass the parameter on in the navigation.
{% set isFeatured = (craft.request.getParam('v') == 'featured') ? true : false %}
{% if isFeatured %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.featured) %}
    {% nextUrl = entry.getNext(params).url ~ '?v=featured' %}
    {% prevUrl = entry.getPrev(params).url ~ '?v=featured' %}
{% else %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.galleries) %}
    {% nextUrl = entry.getNext(params).url %}
    {% prevUrl = entry.getNext(params).url %}
{% endif %}


Abstract the relationship by creating a new 'featured' entries channel, with an entries field that links to the actual entry. Then the 'featured' category can link to the 'featured' entries (which are subsequently linked to the real entries). The featured template can then just include the normal entry with a variable isFeatured=true or something.
// In 'featured' entry template
{% include 'mychannel/_entry' with { entry: entry.myEntriesField, isFeatured: true } only %}

// In native entries template
{% if isFeatured %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.featured) %}
{% else %}
    {% set params = craft.entries.section('galleries').relatedTo(categories.galleries) %}
{% endif %}


I'm sure there are more but one those might work.


---

