I am trying to use templates in embeds depending on the users' category selection but I don't know how to check if a category has been assigned or not.

    {if category_url_title=="full-page-review"}
        {embed="temp-group/.full_page_review" entry_id="{entry_id}"}
    {if:elseif category_url_title=="standard"}
        {embed="temp-group/.standard" entry_id="{entry_id}"}

This works fine as long as a category has been assigned in the entry, but nothing happens if the author forgot to assign a category. Is there a way to see if there is a category assigned or not while using a conditional like this?

2 Answers 2


I was able to accomplish what I was after using the following...

{if "{categories}{category_url_title}{/categories}"!=""}
  • Super helpful, thanks @Brian! I extended your above example to display different Freeform headers {exp:freeform...} based on category_group: {if "{categories}{category_group}{/categories}"!="1"} INCLUDE THIS HEADER
    – Dan
    Commented Sep 26, 2015 at 5:43

I use Switchee to check for the length of a string (e.g. for a change in design if title is too long). I suppose it could be adapted to check if the string is empty or not:

      {exp:switchee parse="inward" variable="{categories}{category_url_title}{/categories}"}
        {case value="full-page-review"}
          {embed="temp-group/.full_page_review" entry_id="{entry_id}"}
        {case value="standard"}
          {!-- just here as an example --}
          {embed="temp-group/.standard" entry_id="{entry_id}"}
        {case value="#^.{1,}$#"} 
        {!-- regex of ^.{1,}$ means match any character of 1 or more,
             I would have another number after the comma though. 
             You could just try #^.+$# instead, don't see why that wouldn't work --}
          {!-- unaccounted for case, but category exists --}
          {embed="temp-group/.standard" entry_id="{entry_id}"}
        {case default="Yes"}
          {!-- unaccounted for case, category DNE --}
          {embed="temp-group/.standard" entry_id="{entry_id}"}

The above assumes that {category_url_title} will not leave whitespace before/after it.

  • I used my solution since it does not require the use of more addons. ;)
    – W3bGuy
    Commented Dec 5, 2013 at 19:16
  • Yeah I just posted mine in case it might be of use to someone down the line (in the case they're looking for a string length limitation). With this you also won't have to use advanced conditionals if you want more checks when the category_url_title isn't empty.
    – notacouch
    Commented Dec 5, 2013 at 19:45

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.