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

Plugin: Child Categories

Development and Programming

Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi smartpill,

from which place into which new place you need to move content? And which content it is?

       
smartpill's avatar
smartpill
456 posts
15 years ago
smartpill's avatar smartpill
Hi smartpill, from which place into which new place you need to move content? And which content it is?

Within the child categories is a field “f_chair” if this is not empty (starts line 11 above):

{if '{exp:single_field field="f_chair" entry_id="{entry_id}"}' != ''}
{exp:replace_plus find='<p>{exp:single_field field="f_first" entry_id="{entry_id}"} 
{exp:single_field field="f_last" entry_id="{entry_id}"}, <i>Chair</i></p>'}{/exp:replace_plus}{/if}

I want that content to appear right after <div class=”staffList”> which I have (see line 4) as

{replace_area}{/replace_area}

Basically it should appear as if it were the single entry in the parent category. I’m using the parent categories as a “Department” and the child categories as “Programs” within the Department. Each entry is for a staff member who is assigned to a “Program” (a.k.a “child category”) as an entry.

One staff member (entry) is also “Department Chair”. This is indicated by checking a box in the field “f_chair”. Those people are listed in two places, a “Program” (child category) and need to be additionally listed as I’ve indicated above.

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi smartpill,

From my point of view, your main problem is this: you need to get the output of conditional

{if '{exp:single_field field="f_chair" entry_id="{entry_id}"}' != ''}
{exp:single_field field="f_last" entry_id="{entry_id}"}, <i>Chair</i>{/if}

and only then to move the output if available.

This is not possible using usual conditionals.

My suggestion is this: at first get the code

{exp:single_field field="f_last" entry_id="{entry_id}"}, <i>Chair</i>

outputted inside correct child categories using Switchee plugin v1.5 and its

excise="min"

parameter. Then it will be possible to move this piece of code inside the output of {parent_category_start}{parent_category_end} variable pair by using Reeposition plugin.

       
smartpill's avatar
smartpill
456 posts
15 years ago
smartpill's avatar smartpill

OK. Sooooooo close.

Only problem now is the line moved with Reeposition only outputs the last item that matches the Switchee condition, so I get the same data every time. Look at example here. You’ll see the lines under “Department” that end with “chair” list the same person when they should be different. But everything else is perfect.

Here’s the most current code:

{exp:reeposition}
{exp:child_categories parent="13|14" show_empty="no" weblog="faculty" parse="inward"
 entries_sort_by="title" entries_sort_direction="asc"}
{parent_category_start}
<h4 id="oc_{parent_category_url_title}" class="h_rule">{parent_category_name} Department</h4>
<div class="staffList">{reeposition:put_item}{parent_category_end}
{child_category_start}
<h4>{child_category_name}</h4><div>{child_category_end}
{entries_wrapper_top_start}
<ul>
{entries_wrapper_top_end}
{entries_start}
{exp:switchee variable="{exp:single_field field='f_chair' entry_id='{entry_id}'}" excise="min"  parse="inward"}
{case value="y"}{reeposition:item}{exp:single_field field="f_first" entry_id="{entry_id}"} 
{exp:single_field field="f_last" entry_id="{entry_id}"}, <i>Chair</i>{/reeposition:item}
{/case}
{case default="Yes"}<li>{exp:single_field field='f_first' entry_id='{entry_id}'} 
{exp:single_field field='f_last' entry_id='{entry_id}'}</li>{/case}
{/exp:switchee}
{entries_end}
{entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}
{/exp:child_categories}
{/exp:reeposition}
       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi,

You don’t use “id” parameter of {reeposition:item} and {reeposition:put_item} variables. Try this code:

{exp:reeposition}
{exp:child_categories parent="13|14" show_empty="no" weblog="faculty" parse="inward"
entries_sort_by="title" entries_sort_direction="asc"}
{parent_category_start}
<h4 id="oc_{parent_category_url_title}" class="h_rule">{parent_category_name} Department</h4>
<div class="staffList">{reeposition:put_item id="chair_{parent_category_id}"}{parent_category_end}
{child_category_start}
<h4>{child_category_name}</h4><div>{child_category_end}
{entries_wrapper_top_start}
<ul>
{entries_wrapper_top_end}
{entries_start}
{exp:switchee variable="{exp:single_field field='f_chair' entry_id='{entry_id}'}" excise="min"  parse="inward"}
{case value="y"}{reeposition:item id="chair_{parent_category_id}"}{exp:single_field field="f_first" entry_id="{entry_id}"}
{exp:single_field field="f_last" entry_id="{entry_id}"}, <i>Chair</i>{/reeposition:item}
{/case}
{case default="Yes"}<li>{exp:single_field field='f_first' entry_id='{entry_id}'}
{exp:single_field field='f_last' entry_id='{entry_id}'}</li>{/case}
{/exp:switchee}
{entries_end}
{entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}
{/exp:child_categories}
{/exp:reeposition}
       
smartpill's avatar
smartpill
456 posts
15 years ago
smartpill's avatar smartpill

I had no idea you could do that! Looks like it’s working now. You Sir, are a genius.

Thanks again.

       
October11's avatar
October11
183 posts
15 years ago
October11's avatar October11

Hello and thanks for this great plugin!

I’ve been using it extensively to sort through a long list of sub-categories within a category group.

One thing I cannot manage to do is stop the plugin from showing future entries.

Is there any way to accomplish this?

Cheers!

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi,

Currently it is not possible to avoid displaying future entries.

I will have in mind this issue when releasing a new version.

       
Christopher Kennedy's avatar
Christopher Kennedy
44 posts
15 years ago
Christopher Kennedy's avatar Christopher Kennedy

I fear I may be a little bit dense here, but I’m looking to list the other categories that match with my entry in the side menu. I thought I would want to use the sibling tag, but maybe I’m wrong?

When I use this code:

{exp:weblog:entries weblog="projects" disable="member_data|trackbacks" category={segment_2} limit="1"}
{exp:child_categories sibling={category_id}}
    {child_category_name}
{/exp:child_categories}
{/exp:weblog:entries}

I get nothing back. Am I going about this wrong? The URL is http://battlestar.onebrightlight.com/index.php/projects/C4/

       
Christopher Kennedy's avatar
Christopher Kennedy
44 posts
15 years ago
Christopher Kennedy's avatar Christopher Kennedy

Never mind, I got it working with the help of TheTristan:

{exp:child_categories parent="{segment_3_category_parent_id}"}
{child_category_start}
<a href="http://{homepage}/category/{child_category_url_title}/">{child_category_name}</a>
{child_category_end}
{/exp:child_categories}

But now, how do I go about wrapping a <ul> around this entry, short of placing one outside the entire loop?

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi Chris,

About wrapping output of Child categories plugin with <ul> and <li> tagrs read this post.

       
dapacreative's avatar
dapacreative
21 posts
15 years ago
dapacreative's avatar dapacreative

The parent category count tag on my list is outputting the incorrect number of child categories. In fact, there are a few instances where there are no child categories but the count says there is 1. What would be causing this?

It also appears as if the show_empty parameter is not working and is actually causing the wrong count.

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi,

Can you post

1) the code which outputs wrong result;

2) the tree of your categories.

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi agai,

Are you sure you use correct variable? There {parent_category_count} and {parent_category_children_count}. Only the latter variable outputs number of child categories.

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi,

I released version 2.4 of Child Categories plugin.

In this release a bug - future and expired entries being displayed - was fixed.

       
First 22 23 24 25

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.