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.

Dynamic Category Listing

July 13, 2010 2:58pm

Subscribe [4]
  • #1 / Jul 13, 2010 2:58pm

    KAAB

    9 posts

    Hello,

    I have created a drop down menu that exists of a three level category structure, an example of which can be seen below.

    Building Materials (Group)
        Steel Coils (2nd)
        Roofing (2nd)
          Comp (3rd)
          Single Ply (3rd)
          Tile (3rd)
          Accessories (3rd)
        Rebar (2nd)
        Fencing (2nd)
        Polycarbonate (2nd)

    I have three Main Category Groups with several Secondary and Tertiary Categories related to each group. The Secondary and Tertiary Categories need to be dynamically generated as they will change over time and I have been able to work this out in the navigation URL structure. What I am having a hard time with is pulling that dynamic category information from the URL and displaying a list of the Secondary Categories in the content area as well as the Tertiary Categories in the sidebar from the same Secondary Group.

    For example, if I click on Comp from the main navigation, I would like to be able to see two separate lists on the interior page. One that lists all the Secondary Categories (Steel Coils, Roofing, Rebar, Fencing and Polycarbonate) and one that lists all the Tertiary Categories related to Comp (Comp, Single Ply, Tile, Accessories).

    I know that this can be done using a different template for each category, but would really like to see it work dynamically for each category/category group.

    Thanks in advance for the help.

  • #2 / Jul 13, 2010 3:11pm

    Scotta

    136 posts

    Hello,

    Can’t you use conditionals based on the URL segments ?

    Best,
    L.

  • #3 / Jul 13, 2010 3:19pm

    Ingmar

    29245 posts

    Let me move this thread to “CodeShare” for you ...

  • #4 / Jul 13, 2010 3:30pm

    KAAB

    9 posts

    Can you use URL Segments with the category name in the URL? What would that look like in the code?

    {exp:weblog:categories weblog="products" category="{segment_4}" etc}

    Is that right? Or am I off base?

  • #5 / Jul 13, 2010 3:42pm

    Scotta

    136 posts

    I meant :

    {if segment_4 == 'category_name'}
    display subcategories
    {/if}
  • #6 / Jul 13, 2010 4:26pm

    KAAB

    9 posts

    That would work, but that is almost the same as making a new template for each category as I would have to do an if statement for every category that exists in the site. What I am looking for is a dynamic generation of related categories.

    Does that make sense? Is there a way to accomplish that?

  • #7 / Jul 13, 2010 6:26pm

    Boyink!

    5011 posts

    The only solution that comes to mind is using the query module and feeding a selected category to it using a segment variable (assuming all category_url_titles are unique).

  • #8 / Jul 13, 2010 6:28pm

    KAAB

    9 posts

    I can certainly make sure that all category titles are unique. Where can I find the query module?

    Thanks for your response.

  • #9 / Jul 13, 2010 6:30pm

    Boyink!

    5011 posts

  • #10 / Jul 14, 2010 7:50pm

    KAAB

    9 posts

    I am not a SQL Query master by any means, but I have gotten it working for the side bar tertiary section. Still trying to get it working for the secondary section, but making progress.

    Is there any way to generate a list of all categories within a category group based upon which category group you are currently viewing? Or would that only be done via SQL as well?

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

ExpressionEngine News!

#eecms, #events, #releases