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.

Using Category URL's in Links

August 06, 2012 4:07am

Subscribe [3]
  • #1 / Aug 06, 2012 4:07am

    DymaxionWeb

    17 posts

    On my category template pages, the {category_name} doesn’t appear. While investigating the issue, I went to Global Preferences in the Control Panel and set the “Use Category URL Titles In Links?” to “No”. When I did that the {category_name} appeared properly. This, of course, leaves me with a meaningless-to-the-user and unsightly URL with the category’s ID number.

    In sifting through the User Guide, I uncovered the following:

    This preference [“Use Category URL in Titles”] lets the name of each category appear in your URLs rather than the numeric indicator (e.g. “/C12/”) on pages such as your Category Archive page.

    In order to use this feature, you must use the channel= parameter in the following tags, and if you specify multiple channels, they must share identical Category Groups:

      {exp:channel:categories}
      {exp:channel:category_heading}
      {exp:channel:entries}

    On my site (an online magazine), I’m pulling content from multiple channels often within the same channel entries tag. For example:

    {exp:channel:entries channel="journal|primer" limit="2" status="Featured Articles|Second Leads|open"} 
     <section>
      <ul class="featuredArticles">
       <li class="{categories limit='1'}{category_css}{/categories}">
       <article>
        <div class="titleGroup">
        <hgroup>
         <h1>{display_title}</h1>
         <h3>— {subtitle}</h3>
    <p>    </hgroup><br />
        </div><br />
         {image}<br />
         {teaser}<br />
       </article><br />
       </li><br />
      </ul><br />
      </section><br />
    {/exp:channel:entries}

    As far as I can tell, I am using the channel parameter in all the necessary tags and the two channels I’m using share the same Category Groups. Yet when I try to get the URL to include the category name, the {category_name} variables don’t work.

    I am officially stumped. What am I missing?

    -Gamiel

     

     

  • #2 / Aug 06, 2012 4:59pm

    Shane Eckert

    7174 posts

    Hello gamiel.lyons,

    I am sorry to hear you are running into this problem.

    What version of ExpressionEngine are you currently using? I am unable to reproduce this.

    Please let me know.

    Thank you,

  • #3 / Aug 06, 2012 5:19pm

    DymaxionWeb

    17 posts

    Hi Shane,

    I’m running the latest version, 2.52.

  • #4 / Aug 07, 2012 12:13pm

    Boyink!

    5011 posts

    How are you putting the template into category mode?  Just adding the category url title isn’t enough - it also needs the category keyword.

    Are you using the path linking variable to create links from within a category loop of some sort?

  • #5 / Aug 07, 2012 2:32pm

    DymaxionWeb

    17 posts

    The category keyword (“category”) does appear in the url along with the category url title. And, yes, when linking to the category template I’m using the path variable within the {exp:channel:categories} tag. Still, the template doesn’t go in category mode unless I turn off the category url feature.

  • #6 / Aug 07, 2012 2:35pm

    Boyink!

    5011 posts

    You’re sure you have:


    - Entries assigned to the categories
    - Entries with an open status
    - Entries without future publish dates
    - Entries without expiration dates in the past.

    If that’s the case strip your code back to one channel and just the open status.  See if that returns anything.

  • #7 / Aug 07, 2012 3:15pm

    DymaxionWeb

    17 posts

    All entries are assigned categories.
    All entries now have an open status.
    No entries have future publish dates.
    No entries have expiration dates.

    Still nothing is returned, again, not even the category name when it’s corresponding link is clicked on.

  • #8 / Aug 07, 2012 3:16pm

    Boyink!

    5011 posts

    What URL is being generated by the link?

    Can you post your code that’s creating the link?

  • #9 / Aug 07, 2012 3:31pm

    DymaxionWeb

    17 posts

    The url’s show up properly. Example: sitename.com/article-topic/category/architecture

    {exp:channel:categories channel="journal" style="nested" class="list1" category_group="10"}
    <a href="http://{path=article-topic/index}class=current">{category_name}</a>
    {/exp:channel:categories}

    The template returns simply returns all the articles (I’m working with 5 so far in the development phase) regardless of their category.

     

  • #10 / Aug 07, 2012 3:43pm

    Boyink!

    5011 posts

    If you make your category template just:

    {exp:channel:entries channel="journal"} 
     {title}
    {/exp:channel:entries}

    Assuming you have entries in the journal channel to match…what happens?

  • #11 / Aug 07, 2012 4:12pm

    Shane Eckert

    7174 posts

    Hey gamiel.lyons,

    I see that Mike has stepped in to help. Thanks Mike!

    Can you try his last instruction?

    Thank you,

  • #12 / Aug 07, 2012 11:19pm

    DymaxionWeb

    17 posts

    Thanks for your help Shane.

    Mike, when I empty all the code in the category template leaving what you specified, the title to every article published appears side by side. (I don’t know if that’s good or bad…)

  • #13 / Aug 08, 2012 8:02am

    Boyink!

    5011 posts

    Formatting aside, I was hoping to hear that it was doing the category fiter.  Just to be complete - you are always loading this template from a category link so it’s loading in category mode?

    If so, then I’m stumped.

    All I can say is take a look at
    http://www.train-ee.com/courseware/free-tutorials/comments/working-with-categories/

    And see if anything I cover there helps.

  • #14 / Aug 08, 2012 10:19am

    DymaxionWeb

    17 posts

    Yes, I’ve been loading the template from a category link. I’ll go and triple-check my work. At this point I’m hoping I made a mistake somewhere. Because if you’re stumped, then, man…

    I’ll read your post on the subject. And I’ll get back to you with my findings. If push comes to shove, I may have to learn how to love the ugly url’s. Functionality first, right?

    Thanks as always, Mike.

  • #15 / Aug 08, 2012 3:05pm

    Shane Eckert

    7174 posts

    Hey gamiel.lyons,

    Awesome!

    Is there anything else we can do to help?

    Thank you,

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

ExpressionEngine News!

#eecms, #events, #releases