0

I'm trying to write a conditional so that the I can output an active css class when the url segment is the same as the category name. Because the url segment includes dashes between each word and small case and the category name have uppercase characters without dashes the == operator is not evaluating true. Any advise on how to best accomplish this?

My Current Code:

{if segment_4 == category_name}active{/if}

Updated Answer

Found a solution using Low Seg2Cat plugin to get category_id from segment url:

{if segment_4_category_id == category_id}active{/if}

1
  • Great stuff, but you should have posted your answer as an answer ("Answer Your Own Question"). It helps others that have similar issues identify your post as containing the answer not just an abandoned question.
    – Blatant
    Aug 20, 2015 at 16:54

1 Answer 1

2

Found a solution using Low Seg2Cat plugin to get category_id from segment url:

{if segment_4_category_id == category_id}active{/if}

1
  • Upvote for that :) Also, if you can be bothered, come back in a couple of days and accept your answer, you'll get the points and a warm cozy 'helping others' feeling.
    – Blatant
    Aug 20, 2015 at 17:11

Your Answer

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

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