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_url_title} not working as expected.

August 27, 2009 4:03pm

Subscribe [3]
  • #1 / Aug 27, 2009 4:03pm

    Adam McIsaac

    8 posts

    All right, I’m pulling my hair out on this one.

    I have this line of code in my markup:

    {entry_date format='%d %F %Y'} | {categories}
    <em><a href="http://{path={template_group}/{category_url_title}}">_{category_name}</a></em>{/categories}
    </a> | <a href="http://{title_permalink={template_group}/article/}">Permalink</a> 
    | {if allow_comments}<a href="http://{url_title_path={template_group}/article/}">Comments?</a>
     ({comment_total} so far){/if}

           

    It’s wrapped, correctly, in a {exp:weblog:entries} tag pair. The {category_name} is rendering correctly, but {category_url_title} is rendering (in the resulting link) as:

    ../news/{category_url_title/C3/'}

    C3 is the correct category ID, by the way. But the rest of the URL—including curly brackets—is just damned weird. Has anybody run into this before? Is this just some bonehead mistake I’m making?

  • #2 / Aug 27, 2009 4:56pm

    Ingmar

    29245 posts

    Your setup seems a bit off. The path variable requires a template and template: do you have a a template with the name of your category_url_title? Can you try {category_url_title} on its own, as it were, it not within {path}? Also, what version and build of EE are you on?

  • #3 / Aug 27, 2009 5:47pm

    Adam McIsaac

    8 posts

    Thanks for the quick response, Ingmar. I’m using 1.6.8, build 20090723.

    {category_url_title} renders fine when it’s not enclosed in the {path}. What’s more, in a different template, I’m using a similar scheme and it works fine:

    {path='{template_group}/{category_url_title}/news/'}'>More news about {category_name}


    In this case, the tag lives inside a {exp:weblog:entries} loop inside an {exp:weblog:categories} loop (a category archive that is designed to render to newest post in each category, if you’re wondering why). At any rate, it works great.

    What I’m trying to accomplish here is a category archive without having to render the category URL indicator in the URL.

    So in the above example the {template_group}/{category_url_title}/news/ string accesses the index template for the template group, and the rendered URL triggers a set of conditions in that template.

    What I’d like to accomplish with the original path (the one that wasn’t rendering as I expected) was to generate something similar: a URL along the lines of ../index.php/template_group/category_url_title that the conditionals in the index template could sort through and pull the right tag loops. I could build a separate template and do the sort there, but I’m trying to keep the URLs as short as possible.

  • #4 / Aug 30, 2009 3:15pm

    Greg Aker

    6022 posts

    Pinch:

    Would going to:  CP Home ›  Admin ›  Weblog Administration ›  Global Weblog Preferences, and setting a category trigger word do it for you?  Then it would make a URL such as:  template_group/category/category_url_title

    -greg

  • #5 / Aug 30, 2009 3:53pm

    Adam McIsaac

    8 posts

    Well, I had hoped to avoid adding “category” (or any other CP-based trigger word) to the URL. I wanted the URL to run something like this:

    [site root] / programs / [program name] / [entry]

    I eventually did do as you suggested, Greg, because we’re gonna have to launch with something—I used “section” as my category trigger, and the URL looks like this now:

    [site root / programs / home / section / [program name]

    Not ideal, but workable—“home” is the catch-all template, doing service as an archive as well.

    I think I’m probably looking at this wrong, though, because it doesn’t seem like I should have to hard-code templates for each of my program names to get the URL structured like I want (which is the only way I could figure out how to do it).

    I understand the Structure framework allows something like what I want, but that’s not gonna happen for this project.

  • #6 / Aug 30, 2009 4:45pm

    Greg Aker

    6022 posts

    Pinch:

    Why would you have to hard code templates for each program?  If you are using the categories, the content will change based on the trigger.  What am I missing here?  Are they displayed differently?

    Structure is not something I have used, so I’m afraid I can’t say if it would be helpful or not.

    -greg

  • #7 / Aug 30, 2009 5:01pm

    Adam McIsaac

    8 posts

    Sorry, man. I was unclear. The content does change based on the trigger—it works as it should. I’m just kvetching about having those two extra segments in the URL—one for the template, and one for the trigger.

    When I set about this, I had hoped to serve an entire template group from one template—the index—and handle the content triggering with conditionals, thus avoiding having to extend the URL with the category trigger.

    UPDATE

    Disregard subsequent conversation on this thread. FortySevenMedia had figured out what I wanted to do. It was a simple query string. Here’s their writeup, which even a bonehead like yours truly could understand.

  • #8 / Aug 31, 2009 1:29am

    John Henry Donovan

    12339 posts

    Pinch,

    The category trigger is important for a number of reasons. Please review Lisa’s blog post for a greater understanding of the hows and whys.

    EE Blog : The Importance of Semantics: Displaying Categories

    EE Docs : ExpressionEngine URLs

  • #9 / Aug 31, 2009 1:45am

    Adam McIsaac

    8 posts

    I get it, John; and thanks.

  • #10 / Aug 31, 2009 1:47am

    John Henry Donovan

    12339 posts

    Thanks for the update. Feel free to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases