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

Support archive

Is it possible to have different search result url's depending on category?

Jon 23 Oct 2013 21:37 question, complete

I'm having a hard time trying to get the right url in my search results. I have a "faq" collection for a channel that has several categories. The search form returns the right results but I need the url to go to that particular category url.

The search form:

 
{exp:low_search:form collection="faq" search_mode="all" result_page="/support/search"}
<input type="search" name="keywords" id="keywords">
<button type="submit">Search</button>
{/exp:low_search:form}


The search results:
 
{exp:low_search:results collection="faq" query="{segment_3}"}
{if count == 1}<ol>{/if}
<li><a href="/support/{want category name here}/{url_title}">{title}</a></li>
{if count == total_results}</ol>{/if}
{if no_results}No search results{/if}
{/exp:low_search:results}


When showing the categories (in a sidebar that's not related to Low Search) here's the code I'm using:
 
<h4>Help Guides</h4>
{exp:channel:category_archive channel="faq" style="linear" show="not 13"}
<ul>
{categories}
<li><a href="/support/{category_url_title}/">{category_name}</a></li>
{/categories}
</ul>
{/exp:channel:category_archive}

Any help would be appreciated.

Replies

  1. Low 23 Oct 2013 21:43

    You'd have to use something like this in your Results tag, just as you would with the native channel:entries tag:

    <a href="/support/{categories limit="1"}{category_url_title}/{/categories}{url_title}/">{title}</a>

  2. Jon 23 Oct 2013 21:49

    Perfect Low! Kicking myself right now as this is such a simple solution. Thanks so much for the quick turnaround!