I am using Laisvunas' Child Categories plugin on my site and am having some issues with conditionals on setting the selected navigation element for styling purposes.

For example on this page: http://rouviere.com/our-work/ the code for the sidebar navigation is as follows:

<ul id="basic">

    {exp:child_categories parent="102|105" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc"}

        <li><a {if segment_3=="{child_category_url_title}"} class="selected"{/if} 
            {if "{child_category_url_title}" != "photography"}href="{site_url}our-work/category/{child_category_url_title}/{child_category_id}" {/if}
            {if "{child_category_url_title}" == "photography"}href="{site_url}photo/"{/if}>{child_category_name}</a></li>

The navigation works fine, however, I would like to indicate which segment is active. I tried adding the following code (also seen above) to indicate which segment is active:

<a {if segment_3=="{child_category_url_title}"} class="selected"{/if}

Nothing happens. I have tested it by manually entering a child category url title, so I know it works. Any clues on how to get this working properly?


3 Answers 3


I spent some time trying to understand what happens on your code, until I notice the variable "{child_category_end}". This variable shows that the addon Laisvunas' Child Categories doesn't use the template class of EECMS, otherwise the variables would be something like "{child_category}(...){/child_category}".

I can't say for sure without to read the code of the addon, but it looks like to have its own parser and maybe this parser deals with conditionals. If I'm right, the issues you're having aren't problems on EECMS that we can help you with. The solution can be just the space before the "==":

{if segment_3 == "{child_category_url_title}" } class="selected"{/if}


{if segment_3 == {child_category_url_title} } class="selected"{/if}


{if "{segment_3}" == "{child_category_url_title}" } class="selected"{/if}

I can't say for sure and I guess just the developer of the addon can help you.

I don't know the reason you choose this addon, but you can do almost the same using {exp:channel:categories}, selecting one category_group and removing the parent categories you don't want to show.

I hope it helps.

  • Hi Robson, your third option worked. Thank you for taking the time to help me sort this out. Child Categories offers a lot more options for displaying child category information. Thanks again.
    – forrest
    May 13, 2013 at 19:32

have you tried this using category_url_title instead?

{if segment_3=="{category_url_title}"} class="selected"{/if}

Try without the quotes:

{if segment_3 == {child_category_url_title} } class="selected"{/if} 

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.