<p>Try removing the ' ' from segment in line 2</p>

<p>e.g. </p>

<pre><code>{% set pageCats = craft.categories('photoCategories').slug(segment) %}
</code></pre>

CC BY-SA 3.0
2015-01-29T14:28:32.093Z
yes, that worked, and i was sure i'd checked that too!
Samsull
CC BY-SA 3.0
2015-01-29T13:53:05.863Z
2015-01-29T13:53:05.863Z
Dave Coggins
<p>I've seen plenty examples of using the uri segment like below, but it ain't working for me, anyone had same sort of issue?</p>

<pre><code>{% set segment = craft.request.segment(2) %}
{% set pageCats = craft.categories('photoCategories').slug('segment') %}
{% set entries = craft.assets.group('photoUpload').relatedTo(pageCats).find() %}

{% for entry in entries %}
    {{ entry.stuff }}
{% endfor %}
</code></pre>

<p>It works if I hard code the segment name <code>.slug('skateboards')</code> and the segment does render when <code>{{ segment }}</code> on other areas of the same page.</p>

<categories><segments>
Segment to filter through categories slug
# Segment to filter through categories slug

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

I've seen plenty examples of using the uri segment like below, but it ain't working for me, anyone had same sort of issue?
{% set segment = craft.request.segment(2) %}
{% set pageCats = craft.categories('photoCategories').slug('segment') %}
{% set entries = craft.assets.group('photoUpload').relatedTo(pageCats).find() %}

{% for entry in entries %}
    {{ entry.stuff }}
{% endfor %}

It works if I hard code the segment name .slug('skateboards') and the segment does render when {{ segment }} on other areas of the same page.

**Tags:** categories, segments

---

## 1 answers

### Answer by username_1 on 2015-01-29. Score: 4

Try removing the ' ' from segment in line 2
e.g. 
{% set pageCats = craft.categories('photoCategories').slug(segment) %}

> **Comments:**
> **username_0**: yes, that worked, and i was sure i'd checked that too!  

---

