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

Display only child categories in weblog:entries tag

Development and Programming

Gregory Maher's avatar
Gregory Maher
24 posts
17 years ago
Gregory Maher's avatar Gregory Maher

I’m looking to display only the child categories of a parent in an entries loop.

For example, I have a category structure similar to the following:

Parent 1 - Child 1 – Child 2 – Child 3

Parent 2 - Child 1 – Child 2 – Child 3

I am using a URL segment to figure out the parent category, which works just fine (with a bit of PHP to get the category ID from a nice-looking URL). I know there are probably a couple of ways to do this, but my needs are pretty specific. I want to display the parent name, description and a couple other custom fields on the page and then list the entries within the parent, but only show the sub-category name for each entry.

For example:

Page Title: Parent 2 Category Description: Aliquam et nisl vel ligula consectetuer suscipit. Morbi euismod enim eget neque. Donec sagittis massa. Vestibulum quis augue sit amet ipsum laoreet pretium. Nulla facilisi. Duis tincidunt, felis et luctus placerat, ipsum libero vestibulum sem, vitae elementum wisi ipsum a metus. Nulla a enim sed dui hendrerit lobortis. Donec lacinia vulputate magna. Vivamus suscipit lectus at quam. In lectus est, viverra a, ultricies ut, pulvinar vitae, tellus. Donec et lectus et sem rutrum sodales. Morbi cursus. Aliquam a odio. Sed tortor velit, convallis eget, porta interdum, convallis sed, tortor. Phasellus ac libero a lorem auctor mattis. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Entries: Entry 1 (link) Category: Child 1

Entry 2 (link) Category: Child 1

Entry 3 (link) Category: Child 3

So the entries are children of Parent 2, but I don’t want “Parent 2” displayed at the entry level.

Currently I have this working using two category groups, one for the parent, and another for the parent-child relationships. This seems like a lot of overhead though. I’ve explored the subcategories plugin but it didn’t seem to do what I needed. I’ve also explored a custom query, but that got pretty messy based on input/output parsing.

Any help would be appreciated. Thanks!

UPDATE: I’m worried I posted in the wrong Topic but cannot seem to move the post.

       

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.