We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Channel Entries - How do you show "channel category" sub-categories

How Do I?

andrew.reff's avatar
andrew.reff
26 posts
8 years ago
andrew.reff's avatar andrew.reff

Hey everyone! I’m sure this is a simple solution and I am overlooking something here, but I have tried various methods and can’t seem to come up with the correct way to accomplish my goal.

Here is what I have set up in my EE site;

  • Channel: Partners
  • Category Group: Partners - ID: 2 (This is checked on the “Category Groups” page under Edit Channel for Partners). Sub categories of this are oem - ID:4, dms-integrations - ID:5, appraisal-providers - ID:6
  • Template Manager: company/partners

When I create a new channel entry I am tagging that entry with one of the 3 categories listed above.

Below I have pasted what I have currently got working. The bottom half after the {if:else} works perfectly fine, it’s the top part that I can’t figure out. When I click one of the links to take me to one of the specific “partners” I am getting the rendered url “http:/siteaddress.com/company/partners/category/appraisal-providers” (If the bottom half is wrong and that isn’t the right link, please advise in that area as well)

{embed="site/header"}
{if segment_3 == "category"}
<section class="section" id="partner-individual">
 <div class="container">
  <div class="row">
   <!-- THIS IS WHAT I DONT KNOW WHAT TO USE -->
   {exp:channel}
   <h3>{category_name}</h3>
   {category_description}
   {/exp:channel}
  </div>
  <div class="row">
   <ul>
    <!-- THIS IS WHAT I DONT KNOW WHAT TO USE -->
    {exp:channel}
    <li>
     <figure>
      {partner_logo}
     </figure>
    </li>
    {/exp:channel} 
   </ul>      
  </div>         
 </div>
</section>
<!-- -->
{if:else}
<!-- -->
<section class="section" id="partners">
 <div class="container">
  <div class="row">   
   {exp:channel:categories category_group="2"}
   <li>
    <div class="partner-icon">
     <figure>
      {category_image}
     </figure>
    </div>
    <div class="partner-content">
     <h3>{category_name}</h3>
     {if category_description}
     {category_description}
     {/if}
     <ul>
      <li>
       <a href="http://{path=%27company/partners%27}%22class=%22button" class="button button-medium">Learn More <i class="fa fa-arrow-right" aria-hidden="true"></i></a>
      </li>
     </ul>
    </div>
   </li>       
   {/exp:channel:categories}                               
  </div>          
 </div>
</section>   
<!-- -->
{/if}
<!-- -->
{embed="site/footer"}

Any help is greatly appreciated! Thank you!

       
Jeremy S.'s avatar
Jeremy S.
353 posts
8 years ago
Jeremy S.'s avatar Jeremy S.

A few basic things right of the bat:

{exp:channel}
   <h3>{category_name}</h3>
   {category_description}
   {/exp:channel}

should be

{exp:channel:categories}
  <h3>{category_name}</h3>
  {category_description}
{/exp:channel:categories}

and

{exp:channel}
    <li>
     <figure>
      {partner_logo}
     </figure>
    </li>
    {/exp:channel}

should at least be

{exp:channel:entries channel="Partners"}
  <li>
    <figure>
      {partner_logo}
     </figure>
  </li>
 {/exp:channel:entries}
       
andrew.reff's avatar
andrew.reff
26 posts
8 years ago
andrew.reff's avatar andrew.reff

@jeremy so here is what my actual code looks like. The code before was an example;

{embed="site/header"}
{if segment_3 == "category"}
<section class="section" id="partner-individual">
 <div class="container">
  <div class="row">
   {exp:channel:categories channel="Partners"}
   <h3>{category_name}</h3>
   {category_description}
   {/exp:channel:categories}
  </div>
  <div class="row">
   <ul>
    {exp:channel:entries channel="Partners"}
    <li>
     <figure>
      {partner_logo}
     </figure>
    </li>
    {/exp:channel:entries} 
   </ul>
  </div>
 </div>
</section>
<!-- -->
{if:else}
<!-- -->
<section class="section" id="partners">
 <div class="container">
  <div class="row">
   {exp:channel:categories category_group="2"}
   <li>
    <div class="partner-icon">
     <figure>
      {category_image}
     </figure>
    </div>
    <div class="partner-content">
     <h3>{category_name}</h3>
     {if category_description}
     {category_description}
     {/if}
     <ul>
      <li>
       <a href="http://{path=%27company/partners%27}" class="button button-medium">Learn More <i class="fa fa-arrow-right" aria-hidden="true"></i></a>
      </li>
     </ul>
    </div>
   </li>
   {/exp:channel:categories}                               
  </div>
 </div>
</section>
<!-- -->
{/if}
<!-- -->
{embed="site/footer"}

Everything below the {if:else} from the {if segment_3 == "category"} works great and as it should (or so it seems thus far), it’s everything before hand. The actually “channel entries” for the specific partner logos are rendering correctly and on the correct pages. The problem that I am still running into is the following;

{exp:channel:categories channel="Partners"}
   <h3>{category_name}</h3>
   {category_description}
   {/exp:channel:categories}

This shows all 3 categories and their descriptions. I only need it to show the {category_name} & {category_description} of the category it’s actually on.

Feel like sooo close!!! Help is greatly appreciated!

       
Jeremy S.'s avatar
Jeremy S.
353 posts
8 years ago
Jeremy S.'s avatar Jeremy S.

(edit)

Forum is having a fit… see below…

       
Jeremy S.'s avatar
Jeremy S.
353 posts
8 years ago
Jeremy S.'s avatar Jeremy S.

You’re likely looking for:

{exp:channel:category_heading channel='Partners'}
  <h3>{category_name}</h3>
  {category_description}
{/exp:channel:category_heading}

Documentation: https://docs.expressionengine.com/latest/channel/category_heading.html

       
andrew.reff's avatar
andrew.reff
26 posts
8 years ago
andrew.reff's avatar andrew.reff

@jeremy!!! YOU ARE THE MAN! Thank you thank you!!!

       
Jeremy S.'s avatar
Jeremy S.
353 posts
8 years ago
Jeremy S.'s avatar Jeremy S.

Happy to help.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.