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.

Help: Category name in URL's

June 28, 2007 7:52am

Subscribe [1]
  • #1 / Jun 28, 2007 7:52am

    Zlate

    75 posts

    I want to create an URL something like this:

    http://www.site-name.com/template-group/template/category-name/article-name/

    I have a bunch of categories, and articles are in different categories. What I want to accomplish in my URL is for every article URL to have the designated category shown in the URL.

    Is it somehow possible?

  • #2 / Jun 28, 2007 12:53pm

    Robin Sowell

    13255 posts

    Yes, but I wouldn’t recommend it.  If you deviate from the standard url structure, it tends to have a lot of unexpected consequences- it can jam you up on search result links, commenting, next/prev navigation.  I’d advise against it.

    If you really NEED the category in there (and I’ve had situations where I did)- then it’s better to tack the category onto the end of the url.  That way, EE will still react to the url as if it’s a single entry page- with the url_title in the third segment.  The forth segment- which holds the category- it will ignore.  Unless you pull it out with segments.

    How you get the category in the url will depends on where/how you’re linking.  But if it’s in the weblog tag, no reason you can’t tack it onto the url using the categories variable pair:

    {exp:weblog:entries}
    <a href="http://{comment_url_title_auto_path}{categories}{category_name}{/categories}">{title}</a>
    etc…

    Really better if you have access to the category url title.  But that’s the basic logic.

  • #3 / Jul 03, 2007 2:07pm

    Zlate

    75 posts

    I tried putting the category name onto the end of the URL and it basically works. The problem now is that I need some articles that are connected with 2 categories so my URL looks like this

    /articles/article/beyonce-wears-100k-leggings/gossip-and-rantsbeyonce-knowles

    I tried restricting to show only the first type of category but it does not work?

    Here is my code:

    <a href="{title_permalink="group="not 2">

    Or…

    <a href="{title_permalink="group="1">

    The both ways don’t work, is there a third way of solution?

    [Moderator Edit: Merged with original thread]

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

ExpressionEngine News!

#eecms, #events, #releases