ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Category URLs showing non-friendly?

April 30, 2011 11:33pm

Subscribe [3]
  • #1 / Apr 30, 2011 11:33pm

    FuturShoc

    71 posts

    I have a page that lists all categories in my “products” weblog.

    {exp:weblog:categories weblog="jewelry" style="linear" show_empty="yes"}
                  <a href="http://{path=products/category}">{category_name}</a>
                  
                  <hr >
               {/exp:weblog:categories}

    However, when I click on one to go to the category template and list all products in the given category, the resulting URL looks like this, instead of using the category_url_title which is, for example, “diamond_rings”

    <a href="http://www.domain.com/index.php/products/category/C8/">http://www.domain.com/index.php/products/category/C8/</a>

    I want the URL to look like this:

    <a href="http://www.domain.com/index.php/products/category/diamond_rings/">http://www.domain.com/index.php/products/category/diamond_rings/</a>

    The proper item is showing on that category page, but the URL just isn’t constructed using the SEO-friendly name.

    Can someone give me some guidance here?

    Even better, I’d honestly rather not show the “category” template name in the url title, but instead show the URL like this:

    <a href="http://www.domain.com/index.php/products/diamond_rings/">http://www.domain.com/index.php/products/diamond_rings/</a>

    But I’ll live with having the category template name in the URL, if necessary.

  • #2 / Apr 30, 2011 11:50pm

    FuturShoc

    71 posts

    Of course, just after I posted, I discovered the Global Weblog Preferences and the “Category URL Indicator” option.
    Because “category” was the indicator, my template named “category” was also problematic.

    I think I’ve got something workable now. Links are rendering in this form:

    <a href="http://www.domain.com/index.php/products/list/category/diamond_bracelet/">http://www.domain.com/index.php/products/list/category/diamond_bracelet/</a>

    “list” is my new template for showing all items in a given category.

    Is there any other technique which could shorten my URLs to something like this?

    <a href="http://www.domain.com/index.php/products/category/diamond_bracelet/">http://www.domain.com/index.php/products/category/diamond_bracelet/</a>

    “products” is my template group…

  • #3 / May 01, 2011 2:55pm

    Boyink!

    5011 posts

    If you use the index template in your products template group you could achieve that URL.

  • #4 / May 01, 2011 5:56pm

    FuturShoc

    71 posts

    I’m not sure I follow…? “index” as in “list’ or “index” as in the default page on my “Products” template group?

  • #5 / May 01, 2011 6:11pm

    FuturShoc

    71 posts

    Ok, I re-read your reply and see now what you meant. It seems to work! Thank you!

    I’ve reworked the index page of my “category” template group to look like this. The first section shows all my categories as a whole, which I’ll style to be a left navigation sidebar.

    The second section (which is the category title) only displays when the page is loaded with a category link.

    The last section displays the items themselves. When the page loads without a category in the URL, it shows all items.
    If the page loads with a category in the URL, it shows only items in that category.

    Is this approach ok or am I doing anything obviously dumb?

    
    									
  • #6 / May 02, 2011 10:09am

    Boyink!

    5011 posts

    Are you using segments & conditionals in that code to determine what to show?  Sometimes the forum eats those…

  • #7 / May 02, 2011 2:34pm

    MAYO

    53 posts

    How i normally do categories is by setting a custom URL structure using Segments.

    http://www.domain.com/index.php/products/category/category_name

    So in Products template group, in the Index template just do this:

    {if segment_1 == "products" AND segment_2 == "" AND segment_3 == ""}
    
    Product List
    
    {if:elseif segment_1 == "products" AND segment_2 == "category" AND segment_3 != ""}
    
    Product Category List
    
    {/if}
  • #8 / May 02, 2011 6:12pm

    Kevin Smith

    4784 posts

    Thanks for the assist, Mike.

    Did Mike’s help get you the URLs you were looking for, FuturShoc?

    Kevin

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases