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

Support archive

Producing results with category within URL.

ZEDG 13 Jan 2015 06:50 question, complete

Hi,
I need to know if Low Search can produce the correct url of entries/pages if a category appears within the url. So..

The page url's to each product appear like so:

site.com/product-range/beauty/brand/beautyproduct1
site.com/product-range/hair/brand/hairproduct1

Beauty, Hair, Nails, etc. are 'Categories'. Within each of these categories are all the related brands.

The href to a product (entry in the cms) is like so: href="/beauty/{categories}{category_url_title}{/categories}/{url_title}"

With the native EE Search function, to produce results i am using

{title}

What that produces is: site.com/product-range/beauty/beautyproduct1

..which leaves out the 'brand' since all brands are 'categories', and are not inserted automatically into the url. Can Low Search see what category is assigned to the product and then add the related 'brand' into the required spot in the url?

Replies

  1. Low 13 Jan 2015 08:29

    The Results tag is basically just the native Channel Entries tag, but with added functionality. The way you would compose URLs there, is exactly the same as like you would with the exp:channel:entries tag. There is no {auto_path} var in there, so I'd just use the method in your first example.

  2. ZEDG 13 Jan 2015 10:49

    Cheers for the reply, but not sure what you mean. I have not been able to determine how to display the relevant category in the native search results 'url'.

    I needed to know whether there was some kind of functionality in Low that allows you to insert the category in the url search results.

    I didn't provide an actual example in my question. (?)

  3. Low 13 Jan 2015 10:54

    The example I referred to that you mentioned, is:

    href="/beauty/{categories}{category_url_title}{/categories}/{url_title}"


    That would be the way to do it. Usually, if you're outputting entries from multiple channels, you'd use an if-statement to output the link per channel, eg:

    {if channel_short_name == 'foo'} 
    {path="foo/{url_title}"}
    {if:elseif channel_short_name == 'bar'}
    {path="bar/{categories limit="1"}{category_url_title}/{/categories}{url_title}"}
    {if:else}
    ...something else
    {/if}

  4. ZEDG 13 Jan 2015 13:04

    OH THANK YOU so much.
    I could not get an answer anywhere to this problem and could not work it out, so assumed that the only solution was to incorporate a 'search' add-on.

    (Sorry for the unrelated product question then.)

    Much appreciated.