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

horizonvp's avatar
horizonvp
107 posts
16 years ago
horizonvp's avatar horizonvp

Actually, I misspoke. What I was trying to do was dynamically get a “child category ID” on a single entry page. Ideas?

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas
What I was trying to do was dynamically get a “child category ID” on a single entry page. Ideas?

Child categories plugin has variable {child_category_id}. I do not understand what’s so problematic about single-entry page.

Can you post some code which does not output something which you think it should output?

       
horizonvp's avatar
horizonvp
107 posts
16 years ago
horizonvp's avatar horizonvp

I was hoping to use the category_id and the child_category_id to be able to pull in the entries from a specific subcategory. Since a single entry page doesn’t have anything in the URL to pull category info I haven’t been able to pull entries ONLY from the subcategory of the current single entry.

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

Hi horizonvp,

It is allways possible to pass category info through URL. For example, you can do it by forming URL using category_url_title:

{path=my_template_group/my_template/category/category_url_title}{url_title}/

If you do this, then segment_4 will be category_url_title. Then you will be able to get category id number using Category Id plugin.

       
heaversm's avatar
heaversm
197 posts
16 years ago
heaversm's avatar heaversm

Hmmm…tried unwrapping the category tag…also ensured that proper “”s were used. Still nothing. Here’s an example again. Am I missing something?

{exp:child_categories parent="12"}
    {child_category_start}
    {child_category_name}
    {child_category_end}
{/exp:child_categories}
       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi heaversm,

The code you provided works on my ExpessionEngine installation correctly.

If it does not work for you, then you may try:

1) doublecheck if “12” is really a number of a category which has some subcategories and those subcategories have some entries (plugin has “show_empty” parameter set to “no” by default)

2) uninstall and install the plugin;

3) try to type your code on a blank template.

If after trying this it still does not work for you, then I’m afaid I cannot help anymore.

       
Maurice's avatar
Maurice
9 posts
16 years ago
Maurice's avatar Maurice

Hi,

I have a strange problem:

My category structure:

  • Project (id = 17) — project beschrijving — Locatie en omgeving — Foto’s — Contact informatie

  • Wijn (id = 18) — Wijn algemeen — Soorten en kenmerken — Onze wijnkelder — Wijn foto’s

  • Ons Weblog (id = 33) — Het avontuur

I use this code to display the main category and the subcategories in a menu:

{assign_variable:site_weblog="site"}
{assign_variable:site_group="live"}
{assign_variable:c_template="cat"}

<div id="header">
  <div id="navigation_top">
    <ul>
      <li><a href="#">home</a></li>
      <li><a href="#">contact</a></li>
    </ul>
  </div>
  <div id="navigation_main">
      {exp:weblog:categories show="17|18|33" weblog="{site_weblog}"}
        <div class="tab{if category_id == 17} first{if:elseif category_id == 33} last{/if}">
                <h1>{category_name}</h1>
        {exp:child_categories parent="{category_id}" child_categories_sort_by="custom"}
          {child_category_start}
            <a href="http://{homepage}/{site_group}/{child_category_url_title}/">{child_category_name}</a>
          {child_category_end}
        {/exp:child_categories}
       </div>
    {/exp:weblog:categories}
    
  </div>
</div>

Somehow, the following child categories are not diplayed:

Foto’s (parent = Project) Wijn Foto’s (parent = Wijn) Het avontuur (parent = Ons Weblog)

I cannot figure out what the problem is, maybe someone can help me?

The website = http://italie.omvantedromen.nl

       
Maurice's avatar
Maurice
9 posts
16 years ago
Maurice's avatar Maurice

I already find out what the problem was, the missing categories didn’t had any entries.

       
odspi's avatar
odspi
29 posts
16 years ago
odspi's avatar odspi

This plugin has been really useful, Thanks!

One thing I did that you may want to add to another release is enclosing text output in htmlentities() calls. For XHTML strict.

       
tristanbailey's avatar
tristanbailey
31 posts
16 years ago
tristanbailey's avatar tristanbailey

Getting errors for empty vars in the category tree:

Notice: Undefined variable: parent_cat_description in /home/public_html/core/plugins/pi.child_categories.php on line 426

Notice: Undefined variable: parent_cat_image in /home/public_html/core/plugins/pi.child_categories.php on line 427

strange as this is a page where they will not show, but can i suppress the errors or will i need to enter values in the category pages?

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

Hi Tristan,

Can you post the code which trigers this error message?

       
tristanbailey's avatar
tristanbailey
31 posts
16 years ago
tristanbailey's avatar tristanbailey

typical it has run away and stopped showing up, will get back to you 😉

       
Gabriel's avatar
Gabriel
130 posts
16 years ago
Gabriel's avatar Gabriel

@Laisvunas: awesome plugin!! Thank you!

I’m trying to create following schema with date range - date of the first and last entry.

Category name
-- Parent category 1 (12 entries / 12-08-2008 - 25-09-2008)
-- Parent category 2 (8 entries / 08-03-2007 - 14-10-2008)

Is it possible?

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

Hi Gabriel,

I’m not sure I understood you correctly.

Is your category a child of Parent category 1 and the Parent category 1 is a child of Parent category 2 ?

       
Gabriel's avatar
Gabriel
130 posts
16 years ago
Gabriel's avatar Gabriel

Parent category = child category

Parent category 1 and Parent category 2 are on the same level.

For better explanation, I’m using code:

{exp:child_categories parent="5" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" site="1"}

{parent_category_start}
  <h1><a href="http://{homepage}entry/{parent_category_url_title}/">{parent_category_name}</a></h1>
  {parent_category_end}
  {child_category_start}
  <h2><a href="http://{homepage}entry/{child_category_url_title}/">{child_category_name}</a></h2>
  Performances: {entries_total}

  {child_category_end}
  {/exp:child_categories}

It generated something like this:

Live performances

1980 The Bridgehouse Era
Performances: 46

1981 New Life Tour
Performances: 12

But, I would like to display date range (date of the first and last entry in the child category).

Live performances

1980 The Bridgehouse Era (from 8.1.1980 to 24.4.1980)
Performances: 46

1981 New Life Tour (from 6.6.1981 to 20.9.1981)
Performances: 12

I think it’s not possible, but better to ask author 😉

       
First 3 4 5 6 7 Last

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.