I'm using Low Seg2Cat to retrieve the third segment of my url and pass it as category to filter a listing page. Problem is that when third segment is empty I have no-results, where I was expecting a full list.

Here my code:

{exp:channel:entries channel="my_channel" category="{segment_3_category_id}"}

URL : my_template/my_category [wohoo, get right result!]
URL : my_template/ [uh oh, no results at all :'/ ]

Normally in a situation with an empty category i.e. category="" it returns all results, so it is like Seg2Cat is passing some kind of string filtering category with one that doesn't exists.

For instance, this code works just fine, it returns all posts:

{exp:channel:entries channel="my_channel" category=""}

Any idea?

1 Answer 1


By default the Seg2Cat extension will only populate the {segment_n_category_id} vars if the corresponding segment is present. So in your case when segment 3 is blank the {segment_3_category_id} var does not exist so it's passed to the channel entries tag as a raw string.

To fix this you can tweak the extension settings and set "Set all segments" as Yes. This will ensure that an empty var will be set if no match is found and the channel entries tag should behave as intended.

  • 1
    Just to clarify Dom's answer when segment_3 is blank EE treat the tag as a string, so will try and find category "{segment_3_category_id}" rather than "". Jan 9, 2013 at 13:28
  • great explanation, now works as intended.
    – Daniele
    Jan 9, 2013 at 18:53
  • If you do set that setting (set all segments) and you do want that nothing shows up (e.g. invalid categories) you can prepend a zero to the parameter. e.g. categories="0|{segment_3_category_id}"
    – GDmac
    Jan 15, 2013 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.