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.

Trying to show a list of 2 categories

June 12, 2012 8:59pm

Subscribe [1]
  • #1 / Jun 12, 2012 8:59pm

    Dotgarden

    216 posts

    Hi,

    I need to create a 2 column list. It’s for a list of board members of an organization. They want 2 categories, “board member” and “board officer”. So, I created 2 categories, and assigned at least 1 person to each category. I have a number of custom fields I want to show. So, it would be a page with two columns, in one column, are the “board member” folks. In the other list, would be the “board officer” folks including custom fields.

    Here’s the code I am using. It’s not showing me any of the fields, just the category title.

    {exp:channel:categories channel="board"}
      <h1>{category_name}</h1> 
      {exp:channel:entries channel="board" category="{category_id}" sort="asc" dynamic="off"} 
        {title}, {board_position}, {board_bio}
      {/exp:channel:entries}
    {/exp:channel:categories}

    I’ve tried replacing {category_id} with the actual category number, still nothing.

    Is there a better way? Running 2.5.2 newest version.

  • #2 / Jun 13, 2012 4:55pm

    Dan Decker

    7338 posts

    Hi Evoir,

    The problem here is nesting. You can’t nest a channel entries tag inside a channel categories tag, at least not directly. You can do this with an embed:

    {exp:channel:categories channel="board"}
      <h1>{category_name}</h1>
    {embed="board/members" cat_id="{category_id}"} 
    {/exp:channel:categories}

    Then the embed template:

    {exp:channel:entries channel="board" category="{embed:cat_id}" sort="asc" dynamic="off"} 
        {title}, {board_position}, {board_bio}
      {/exp:channel:entries}

    Let me know if that works.

    Cheers,

  • #3 / Jun 14, 2012 11:05pm

    Dotgarden

    216 posts

    Nevermind. It worked perfectly. Thank you.

  • #4 / Jun 18, 2012 3:49pm

    Dan Decker

    7338 posts

    Hi Evoir,

    Excellent!

    If you need anything else, please just let us know.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases