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.

Nesting Loops - Categories / Articles...

November 21, 2007 9:54am

Subscribe [1]
  • #1 / Nov 21, 2007 9:54am

    nimzie

    45 posts

    <ul class="submenu">
         {exp:weblog:categories weblog="{segment_2}" style="linear" }
           <li><a >{category_description}</a></li>
        {/exp:weblog:categories}
      </ul>

    Builds me a sweet menu as seen at :

    http://seejeffrun.ca/eengine/index.php/oldcreel/products/

    All of the articles in the right (main) area of the page is stored internally in categories.

    What I want to do is have a + beside Kayaks that is clickable (to expand) and then lists all of the articles in the Kayaks Section. As per the rest of my code, I am keeping this dynamic and having fun with it all now.

    Can someone please advise as to a resource or technique to make a hierarchical menu as per:

    - Category
    |___Article
    |___Article
    - Category
    |___Article
    + Category

    I’d prefer the simplest way to do this. Have seen some AJAX solutions but have never used AJAX before. If anyone has a step by step or some sample code they can offer, that would be amazing.

    Thanks for the help.

    Cheers,

    Adam
    etc…

  • #2 / Nov 21, 2007 10:02am

    Robin Sowell

    13255 posts

    I’m going to shift this on over to ‘How to’- as the show/hide bits aren’t built into the tags.  I swear I’ve seen an ajax approach to it before- so I’ll search around and see if I can spot it.

    In the meantime, check out the category archive tag- it will get you your articles under their appropriate cats- and may prove a better approach to the problem.

    Make sense?

  • #3 / Nov 21, 2007 10:09am

    nimzie

    45 posts

    I tried:

    {exp:cat_expand:wrapper}
    {exp:weblog:categories weblog="{segment_2}" style="nested"}
    {exp:cat_expand:expander category="{category_id}" active-style="font-weight:bolder;"}
    <a href="{path={segment_1}/{segment_2}}">{category_description}
    {/exp:cat_expand:expander}
    {/exp:weblog:categories}
    {/exp:cat_expand:wrapper}

    Using the Expander plugin found at:
    http://gadgets.silenz.org/index.php/gadgets/item/3-level-expanding-category-based-menu/P6/
    for EE1.6

    It doesn’t work. It shifts my nav to the right (nesting cause it’s not top level (first problem).
    No sub items show.
    Boo :(

  • #4 / Nov 21, 2007 10:50am

    nimzie

    45 posts

    I’m going to shift this on over to ‘How to’- as the show/hide bits aren’t built into the tags.  I swear I’ve seen an ajax approach to it before- so I’ll search around and see if I can spot it.

    In the meantime, check out the category archive tag- it will get you your articles under their appropriate cats- and may prove a better approach to the problem.

    Make sense?

    Thanks - I sort of got it working.

    When I’m in a category page, I just want to show that cat / articles for that cat.

    {exp:weblog:category_archive weblog="{segment_2}"style="linear"}
        {categories}
        {if category_description}
         <li><a >{category_description}</a></li>
        {/if}
        {/categories}
        
        {entry_titles}
            <li><a >{title}</a></li>
        {/entry_titles}
    
      {/exp:weblog:category_archive}

    Is bringing me everything back.

    I figure I should be able to code this:

    Note : in my Show parameter within the Category request .. I don’t know how to get an ID for the cat I’m in while I’m in the exp:weblog:category_archive tag

    {if category_request}
      {exp:weblog:category_archive weblog="{segment_2}"style="linear" show="???????"}
        {categories}
        {if category_description}
         <li><a >{category_description}</a></li>
        {/if}
        {/categories}
        
        {entry_titles}
            <li><a >{title}</a></li>
        {/entry_titles}
    
      {/exp:weblog:category_archive}
      {if:else}
      {exp:weblog:category_archive weblog="{segment_2}"style="linear"}
        {categories}
        {if category_description}
         <li><a >{category_description}</a></li>
        {/if}
        {/categories}
        
        {entry_titles}
            <li><a >{title}</a></li>
        {/entry_titles}
    
      {/exp:weblog:category_archive}
      {/if}

    Am I close??

    Please advise.

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

ExpressionEngine News!

#eecms, #events, #releases