Hi Luc,
If you need to output one child category the entry was posted into, then it seems that you can achieve this using Entry Categories plugin.
Quick question here: I really appreciate this plugin and just have one question. I am using the children categories to generate a series of dynamic pages and it works great. On those pages I need to be able call the category id of that page to pull in the entries for that category.
I need something like this:
{exp:weblog:entries weblog="news" category_id={child_category}...}
How do I do this?
Thanks.
Thank you for the prompt reply.
This is what I have done:
{exp:child_categories parse="inward" }
{exp:weblog:entries weblog="event" category="{child_category}" disable="trackbacks|pagination|member_data" }
<h3><a href="#">{title}</a></h3>
<div>
<strong>Name of Organization</strong>: {organization}
<strong>Location and Time</strong>: {location_time}
<strong>Activity/responsibility</strong>: {event_description}
<strong>Tools or skills required</strong>: {tools}
<strong>Ages</strong>: {age_limit}
<strong>Family Friendly</strong>: {family_friendly}
<strong>Additional Notes</strong>: {additional_info}
<strong>Download flyer</strong>: {flyer}
<strong>Links</strong>: {link-1}
{link-2}
{event_photo}
<strong>Contact Person</strong>: {contact_person}
{/exp:weblog:entries}
{/exp:child_categories}
Is this correct - as it doesn’t appear to work.
Edit: Solved, look at the bottom!
Hi… great plugin 😊
I need some help
I want to display Parent as h1, and bellow to display all child’s. Problem is that I want always to show parent in H1, and bellow child’s on the same page.
For example:
Parent preview: www.domain.com/categories/list/computers
<h1>Computers</h1> – Hardware – Software
Child preview: www.domain.com/categories/list/hardware
<h1>Computers</h1> – Hardware – Software
Looks simple but I’m confused Thanks in advance
******** SOLUTION Maybe someone will need it sometime 😊
Template with include:
{exp:weblog:category_heading weblog="question" disable="pagination|trackbacks"}
{if {parent_id} > 0}
{embed="inc/.cat_heading" my_parent="{parent_id}"}
{if:else}
{embed="inc/.cat_heading" my_parent="{category_id}"}
{/if}
{/exp:weblog:category_heading}
Include file:
{exp:child_categories parent="{embed:my_parent}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" category_group="2"}
{parent_category_start}
<h1>{parent_category_name}</h1>
{parent_category_end}
<hr >
{child_category_start}
<a href="http://{homepage}category/list/{child_category_url_title}" class="active">{child_category_name} ({entries_total})</a>
{child_category_end}
{/exp:child_categories}
Not sure if this is the “official” thread for this plugin, but here goes:
There’s a bug (as far as I can tell) with the {entries_total} tag - it doesn’t take the dates of an entry into account when calculating the count, so I have categories being listed with articles despite their publication date being in the future.
I’m about to dive into the plugin to see if I can figure out how to fix it - I’ll post here if I figure out a patch.
Here we go:
Around line 616 or so, replace this code:
// the case "show_expired" parameter is not set to "no"
if ($show_expired !== 'no')
{
$entries_total = $querynext->num_rows;
}
// the case "show_expired" parameter is set to "no"
else
{
$entries_total = 0;
foreach($querynext->result as $rownext2)
{
//echo 'current_time: '.$current_time.' expiration_date: '.$rownext2['expiration_date'].'
';
if ($current_time < $rownext2['expiration_date'] OR $rownext2['expiration_date'] == 0)
{
$entries_total++;
}
}
}
with this code, which compares the current time against the entry_date of the weblog entry before adding it to the count:
// the case "show_expired" parameter is not set to "no"
if ($show_expired !== 'no')
{
$entries_total = 0;
foreach($querynext->result as $rownext2)
{
if ($current_time >= $rownext2['entry_date'] OR $rownext2['entry_date'] == 0)
{
$entries_total++;
}
}
}
// the case "show_expired" parameter is set to "no"
else
{
$entries_total = 0;
foreach($querynext->result as $rownext2)
{
if (($current_time >= $rownext2['entry_date'] OR $rownext2['entry_date'] == 0) && ($current_time < $rownext2['expiration_date'] OR $rownext2['expiration_date'] == 0))
{
$entries_total++;
}
}
}
I have a template that display all my parent categories like so:
{exp:weblog:categories weblog="links" cache="yes" refresh="100" style="linear" show_empty="no"}
<h2><a href="http://{path=site/links_sub}">{category_name}</a></h2>
{if category_description}
{category_description}
{/if}
{/exp:weblog:categories}
When you click the link (category_name), I want to go to a new template (links_sub) display the Parent Category name as a heading, then a sub heading of the 1st sub category then all the weblog entries in that sub category,
then the second sub category and all the weblog entries for the 2nd sub category, then the 3rd sub category etc.
The following code is not working of me.
{exp:weblog:categories category_group="3" weblog="links" limit="1"}
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="99"}
{parent_category_start}
<h1>{parent_category_name}</h1>
{parent_category_end}
{child_category_start}
<h3>{child_category_name}</h3>
{child_category_end}
{entries_start}
<h2>{title}</h2>
{link_url}
{link_desc}
{entries_end}
{/exp:child_categories}
{/exp:weblog:categories}
it seems to display everything in the links weblog and the custom fields in the entries are not working as well. How do I limit it to just the parent and children categories based on the link segment. ie: http://site.com/index.php/site/links_sub/C47/
Where C47 is the ID of the parent category
any help is appreciated.
(EDIT: Solved the custom fields using the sing;le fields plugin and parse inward variable, but still having trouble limiting the category to just the one in the url C47, still displaying everything in the links weblog)
Hi,
Use in addition Find and Replace Plus plugin:
{exp:replace_plus find="C" parse="inward"}
{exp:weblog:categories category_group="3" weblog="links" limit="1"}
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="99"}
{parent_category_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h1>{parent_category_name}</h1>
{/if}
{parent_category_end}
{child_category_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h3>{child_category_name}</h3>
{/if}
{child_category_end}
{entries_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h2>{title}</h2>
{link_url}
{link_desc}
{/if}
{entries_end}
{/exp:child_categories}
{/exp:weblog:categories}
{/exp:replace_plus}
EDIT: SOLVED: forgot an additional parse inward tag. Working code below:
almost there, thanks for your tips on the find replace plus.
I now have the parent, chid, and entries displaying correctly.
but the custom fields in the entries are not displaying using the single field tag:
{exp:replace_plus find="C" parse="inward"}
{exp:weblog:categories category_group="3" weblog="links" limit="1" style="linear"}
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="99" parse="inward"}
{parent_category_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h1>{parent_category_name}</h1>
{/if}
{parent_category_end}
{child_category_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h3>{child_category_name}</h3>
{/if}
{child_category_end}
{entries_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h2>{title}</h2>
{exp:single_field field="link_url" entry_id="{entry_id}"}
{exp:single_field field="link_desc" entry_id="{entry_id}" field_format="raw"}
{/if}
{entries_end}
{/exp:child_categories}
{/exp:weblog:categories}
{/exp:replace_plus}
I am assuming this is something to do with the combination of the 2 plugins? single field and find replace plus?
TIA
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.