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.

Navigation Links using Categories

November 01, 2011 5:51pm

Subscribe [2]
  • #1 / Nov 01, 2011 5:51pm

    Scott Harrington

    85 posts

    Hi, Im after some help with the use of category related posts and displaying in to a template.

    I have 4 category groups each with categories within that I’m using to create a navigation system.

    Pulling in the categories to create the list is fine, which Im doing using the markup below:

    <nav id="secondarynavigation">
           {exp:channel:categories channel="products" category_group="1" show_empty="yes" }
             <a href="http://{title_permalink=%27product%27}" title="Go to {category_name}">» {category_name}</a>
           {/exp:channel:categories}
          </nav>

    However, Im having trouble creating the link that each category creates, ie Im trying to use the ‘permalink’ to push the category related posts out to a template, in this case the template is named ‘product’.

    The above outputs

    http://www.thermoplasticdesignsandlines.co.uk/{title_permalink='product'}

    This makes me assume the permalink method is not working for what I’m trying to achieve?

    Also, once the linking is working, I want the template ‘product’ to display just the content that relates to the category that was clicked.

    Below is the excerpt from the ‘product’ template - would I need to call up anything that relates to the categories within the channel entries tag, or would it be as below?

    <div id="rightcolumnproducts">
          {exp:channel:entries channel="products" sort="asc|desc" orderby="title"}
           {if count == "1"}
           <h3 id="productsforschools">Alphabet & Numbers</h3>
            {/if}
            <div class="productschools_{count}">
            {exp:imgsizer:size src="{product_image}" height="115" width="185"}
             {sized}
            {/exp:imgsizer:size}
             <h4 class="schoolsheading">{title}</h4>
             {product_summary}
             <span>Size:</span> {product_size}
             <span>Price:</span> £{product_price}
            </div>
          {/exp:channel:entries}
          <div class="clear"></div>
                </div>

    Really appreciate any help that can be given on this, having a right nightmare getting to grips with the whole usage of categories….maybe Im just missing the obvious lol.

    Thanks in advance

    Scott

  • #2 / Nov 04, 2011 12:26pm

    Darren Miller

    103 posts

    First thing to do is establish your URL stucture. You might have done this but it’s not clear from your post.

    You’ve got two options:

    /products/Cx  (where x is the category ID) or

    /products/category/category_url_title (where the second segment is the Category URL Indicator in Admin > Channels > Global Channel Preferences)

    Personally I’m no fan of auto-generated URLs and prefer to spell it out in the template so it’s clear what’s happening (I don’t think title_permalink is a valid option anyway). This would make your nav link one of the following:

    <a href="/products/C{category_id}" title="Go to {category_name}">» {category_name}</a>

    or

    <a href="/products/category/{category_url_title}" title="Go to {category_name}">» {category_name}</a>


    the code in your channel entries tag should respond to either of the above so long as you don’t turn off the Dynamic parameter

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

ExpressionEngine News!

#eecms, #events, #releases