All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Category based HTML output

conradical 29 Oct 2013 22:10 question, complete

Is there a way to switch output for different categories. For instance (simplified code..):

{exp:low_search:results query="{segment_3}" limit="15"}
{if category_id == "1"}
< a href="...">{title}< /a>
{if:else}
{title}
{categories}{category_name}{/categories}
{/if}
{if no_results}No search results{/if}{/exp:low_search:results}

I know it doesn't make sense to not have a link in a search result, but it is the concept of displaying different HTML output based on a category ID.

I cannot wrap the entire thing inside the {categories} tag pair because I am using that inside the loop as well.

Thanks!

Replies

  1. Low 29 Oct 2013 22:17

    You'd have to approach it in the same way you would with the channel:entries tag. So something like

    {if '{categories}{category_id}{/categories}' == '1'} 
    ...
    {/if}


    ...but that will only work if the entry has just one category assigned.

  2. conradical 30 Oct 2013 02:16

    Of course! That does the trick. Thanks!