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.

Filter entries by Category

May 31, 2012 5:49pm

Subscribe [2]
  • #1 / May 31, 2012 5:49pm

    ehime

    6 posts

    hey Guys and Gals I’ve been banging my head against this all day and haven’t been able to figure it out
    I have my main category (Products) with subcats like routers, usb, etcetra but have been unable as of yet to figure out how to filter them per page

    So lets set up a quicky to illustrate what I mean.

    Products General page should show all products (aka everything under cat products),
    routers should just show cat routers, usb cat usb you know

    I tried doing this

    <section id="{embed:this_channel}">
       <div class="wrap">
    
        <hgroup>
         <h1>Routers</h1>
         <ul id="prod-subnav">
          <li><a href="http://{path=">Routers</a></li>
          <li><a href="http://{path=">Mobile</a></li>
          <li><a href="http://{path=">Laptop</a></li>
          <li><a href="http://{path=">Tv & DVR</a></li>
          <li><a href="http://{path=">USB</a></li>
         </ul>
        </hgroup>
    
       <ul class='list-column-3'>
    
       {exp:channel:categories}
       {exp:channel:entries channel="{embed:this_channel}" status="{embed:this_status}" limit="{embed:this_limit}" paginate="bottom"}
    
        {if no_results}No Products in this Channel, check channel info?{/if}
    {category_name}1
        {if category_name == "routers"}
    {category_name}2
        <li>
         <hgroup>
          {if product_blurb_image}{product_blurb_image}{/if}
    
          <h1>{title}</h1>{category_name}
          {product_blurb}
         
         </hgroup>
         <a href="http://{comment_url_title_auto_path}class=red-btn">Learn More</a>
        </li>
        {/if}
    
        {if count == total_results}</div><!--/wrap-->{/if}
            {switch="||</ul><ul class='list-column-3'>"}
    
           {paginate}
               <li>Page {current_page} of {total_pages} pages {pagination_links}</li>
           {/paginate}
    
       {/exp:channel:entries}
       {/exp:channel:categories}
       </ul>  
    
       </div
      </section><!--/{embed:this_channel}-->

    But get a blank page with a lot of <li> tags

    trying this

    {exp:channel:entries channel="{embed:this_channel}" category="routers" status="{embed:this_status}" limit="{embed:this_limit}" paginate="bottom"}
    
          {if product_blurb_image}{product_blurb_image}{/if}
    
          <h1>{title}</h1>
    
       {/exp:channel:entries}

    does not filter (I assume exp:channel:entries doesn’t have a var flag for category)

    So I lay it at your feet, since we have our beta launch tomorrow, what can I do to filter
    correctly?

  • #2 / May 31, 2012 5:56pm

    ehime

    6 posts

    Answered my own question, the channel category filter is numeric.

    I quickly ran everything through

    {exp:channel:categories}
      {category_name}: {category_id}
    {/exp:channel:categories}

    to grab my numeric identifier and ran with it from there

  • #3 / Jun 01, 2012 2:03pm

    Shane Eckert

    7174 posts

    Hey ehime,

    Nice work! You are making my job too easy.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases