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.

Passing category ID between templates

March 29, 2011 9:33pm

Subscribe [4]
  • #1 / Mar 29, 2011 9:33pm

    Joff

    28 posts

    I have a three-step user journey, drilling down from parent categories on page #1, child categories on #2 and finally entries on #3. 
    I’m using the Category ID plugin to get the category from the URL.
    By the time I get to #3, I no longer have the category ID which is needed for displaying on that page.

    The code I’m using is as follows.

    Page 1

    {exp:channel:categories channel="products" style="linear" show_empty="no"}
        <a href="http://{path=products/subcat}">{category_name}</a>
    {/exp:channel:categories}

    ...this links to Page 2

    {exp:category_id category_group="6" category_url_title="{segment_4}" parse="inward"} 
        {exp:channel:entries category="{category_id}" style="linear" show_empty="yes" status="open|featured"}
            <a href="http://{permalink=products/detail}">{title}</a>
        {/exp:channel:entries}
    {/exp:category_id}

    ...which in turn links to Page 3

    {exp:channel:entries entry_id="{segment_3}" status="open|featured"}            
        <h1>{title}</h1>
    {/exp:channel:entries}

    What is it I’m doing wrong?  I’m sure there’s an obvious way to dynamically create a path of links through the site as described above, but I’m going round in circles trying to work out what it is.

  • #2 / Mar 30, 2011 1:23pm

    Lisa Wess

    20502 posts

    Hey Joff,

    I’m a bit confused.

    On Page 2 - why do you need that plugin?  The channel entries tag will automatically show entries based on the category so long as the category trigger is in the URL:

    The Importance of Semantics: Displaying Categories.

    As for single entry pages, those do not inherently belong to a category - categories (plural) can be assigned to an entry; so by default they won’t include the category/ies in the URL.  That would be a custom functionality that you’d need to build, and you’d need to account for what happens when there are multiple categories, parent/child categories, etc.  It’s not a simple undertaking, unfortunately.

    Does that help at all?

  • #3 / Mar 30, 2011 1:31pm

    Mark Bowen

    12637 posts

    As for single entry pages, those do not inherently belong to a category - categories (plural) can be assigned to an entry; so by default they won’t include the category/ies in the URL.  That would be a custom functionality that you’d need to build, and you’d need to account for what happens when there are multiple categories, parent/child categories, etc.

    It’s not a simple undertaking, unfortunately.

    It is now thanks to a fantastic plugin that Leon created initially for me after I asked him about another plugin of his and it couldn’t do what I wanted so he went and coded this one up in under a day!! 😊

    Absolutely stellar support from that guy and this is something that I really wish was baked into ExpressionEngine as standard. As it stands the plugin is free though so that’s a bonus! 😊

    GWCode CatMenu Plugin

    An absolutely awesome plugin that and a top notch developer to boot!

    Hope that helps a bit.

    Best wishes,

    Mark

  • #4 / Mar 30, 2011 5:48pm

    Joff

    28 posts

    Does that help at all?

    Hi Lisa, thanks and yes I think it does help!  What I am trying to do is create a typical category-product path through the site.

    So for example:

    Womenswear
    —Vests
    ——Vest01
    ——Vest02
    —Skirts
    ——Skirt01
    ——Skirt02
    —Shoes
    Menswear
    —Shirts
    —Trousers

    etc

    At each level, I would like the full set of page titles, breadcrumbs, etc showing where the current page is in the grand scheme of things.
    Also, at the product level (Vest01) I also want to show other products at that same level.

    Is there an obvious/recommended way to do this?

  • #5 / Mar 30, 2011 6:27pm

    Mark Bowen

    12637 posts

    If you want a breadcrumb trail then take a look at another excellent add-on from Leon :

    GWCode Categories

    Hope that helps a bit.

    Best wishes,

    Mark

  • #6 / Mar 31, 2011 9:23am

    Joff

    28 posts

    Thanks Mark - a great add-on there!

  • #7 / Mar 31, 2011 9:32am

    Mark Bowen

    12637 posts

    Thanks Mark - a great add-on there!

    Yep they both truly are. What’s even greater is the fact that Leon created the one due to something I’d needed to do which no-one else had ever come up with a solution for and he created the plugin in under a day. Now that’s service for you. FREE as well!! Seriously top notch developer and all round nice guy.

    Best wishes,

    Mark

  • #8 / Mar 31, 2011 5:34pm

    Leon Dijk

    131 posts

    Thanks Mark! Can I hire you as an agent? 😉

    Joff, I hope that solves your problem. If not and you think you can use the plugin but need it to be tweaked a bit to your liking, let me know and I’ll see if there’s anything I can do.

  • #9 / Mar 31, 2011 5:47pm

    Mark Bowen

    12637 posts

    Thanks Mark! Can I hire you as an agent? 😉

    How much ‘ya offering? 😉

  • #10 / Mar 31, 2011 6:08pm

    Leon Dijk

    131 posts

    What could a “grad student” offer a “Professor”? 😉

  • #11 / Mar 31, 2011 6:17pm

    Mark Bowen

    12637 posts

    What could a “grad student” offer a “Professor”? 😉

    An apple a day? 😉

  • #12 / Apr 03, 2011 4:08pm

    Greg Salt

    3988 posts

    Hi Joff,

    Do you have this figured out now? Do you need further assistance?

    Cheers

    Greg

    @Leon and Mark, thanks very much for your help.

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

ExpressionEngine News!

#eecms, #events, #releases