<p>Code above is fine. I was stupidly updating the wrong template</p>

CC BY-SA 3.0
2015-11-02T09:03:22.970Z
2015-11-02T09:03:22.970Z
sarah3585
<p>Can anyone shed any light on why the following doesn't work for <code>getSegment(2)</code> but the previous does for <code>getSegment(1)</code>?</p>

<p>URL structure for these two examples are:</p>

<p><code>root.com/blog</code></p>

<p><code>root.com/blog/trends</code></p>

<pre><code> &lt;a class="button button--outline-blue {% if craft.request.getSegment(1) == 'blog' %}current{% endif %}" href="/blog"&gt;All&lt;/a&gt;

{% nav category in craft.categories.group('blogCategories') %}

    &lt;a class="button button--outline-blue {% if craft.request.getSegment(2) == 'trends' %}current{% endif %}" href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;

{% endnav %}
</code></pre>

CC BY-SA 3.0
2015-11-01T15:16:13.157Z
What do you see if you you `{{ dump(craft.request.getSegment(2)) }}` on the  `/blog/trends` page?  Any chance the result you are seeing has to do with CSS styles?  I expect when you say it doesn't work you mean the `current` class is not being added to the a tag in the second example.
Ben Parizek
CC BY-SA 3.0
2015-11-01T15:30:19.153Z
Urgh ignore that question it is working I was just using the wrong template! *Face Palm*

I do have a follow up question on how to make what I've used in the example as 'trends' to be the category title? I've tried what's been updated in the question.
sarah3585
CC BY-SA 3.0
2015-11-01T17:04:00.510Z
Can you add an official answer to your original question and post your follow-up as a new question?
Brad Bell
<navigation><getsegment>
Using getSegment
# Using getSegment

(Asked by: username_0 on 2015-11-01)

Can anyone shed any light on why the following doesn't work for getSegment(2) but the previous does for getSegment(1)?
URL structure for these two examples are:
root.com/blog
root.com/blog/trends
 All

{% nav category in craft.categories.group('blogCategories') %}

    {{ category.title }}

{% endnav %}

**Tags:** navigation, getsegment
> **Comments:**
> **username_1**: What do you see if you you `{{ dump(craft.request.getSegment(2)) }}` on the  `/blog/trends` page?  Any chance the result you are seeing has to do with CSS styles?  I expect when you say it doesn't work you mean the `current` class is not being added to the a tag in the second example.  
> **username_0**: Urgh ignore that question it is working I was just using the wrong template! *Face Palm*  I do have a follow up question on how to make what I've used in the example as 'trends' to be the category title? I've tried what's been updated in the question.  
> **username_2**: Can you add an official answer to your original question and post your follow-up as a new question?  

---

## 1 answers

### Answer by username_0 on 2015-11-02. Score: 2 | Accepted answer

Code above is fine. I was stupidly updating the wrong template


---

