Thanks for your reply agun. I’ve been using those methods successfully for a long time, thanks. The issue here is that Lodewijk’s Find and Replace plugin doesn’t appear to work inside the subcategories plugin (EE is automatically adding index.php to the link urls generated).
I looked inside the module and tried a php str_replace on one of the variables but it didn’t appear to make a difference.
Any ideas anyone?
Hi guys…I am pretty sure that the “index.php” is not ‘hardcoded’ anywhere in EE so therefore if it is showing up as part of a URL, then it is still set somewhere in the CP. Have you checked the “Name of your site’s index page” setting under Admin > System Preferences > General Configuration (plus any other path settings under General Configuration, and the Weblog Administration)?
Hi, I am checking out the plugin and I think it can do what I am hoping for. However I am not exactly getting how to do this right. This is the code:
For some reason the plugin displays the parent category as many times as there are subcategory’s. … Does someone know how I can get it to display the subcategory’s?
Hi, Is there a way to hide a particular subcat with this plugin? Something like:I’m sure it might have been covered in this thread or another, but I can’t see it… Thanks.{exp:subcategories root_node="22" hide="27"} {category_name} {/exp:subcategories}
Sorry I haven’t checked in detail, but could you use a conditional {if] to hide the subcat that you don’t want outputting?
Hi pieshop…without hacking into the plugin code, I don’t think that there is anyway to ‘hide’ a category.
Depending on what you want to do, you could try:
{exp:subcategories root_node="22"}
{if category_id != '27'}
{category_name}
{/if}
{/exp:subcategories}
But of course this will only hide the one category. It will still show the child categories of ‘27’ (if it has some).
There are certainly ways of hacking (or ‘improving’) the plugin by mucking about with the code (note that unless you are an advanced user, or feel really comfortable with PHP, don’t hack the code…small disclaimer!). By changing this (around line 293):
$sql = "SELECT cat_id, cat_name, cat_description, cat_image, cat_order, cat_url_title
FROM exp_categories
WHERE exp_categories.parent_id = '".$DB->escape_str($this->get_root_node())."' AND exp_categories.parent_id ";
to this…
$sql = "SELECT cat_id, cat_name, cat_description, cat_image, cat_order, cat_url_title
FROM exp_categories
WHERE exp_categories.parent_id = '".$DB->escape_str($this->get_root_node())."' AND exp_categories.parent_id NOT IN (".$TMPL->fetch_param('hide').") AND exp_categories.cat_id NOT IN (".$TMPL->fetch_param('hide').")";
You will then be able to set your “hide” parameter to something like this…
{exp:subcategories root_node="22" hide="27,28,31"}
{category_name}
{/exp:subcategories}
Note that they are comma delimited ID’s ONLY! This will remove category id’s 27, 28 and 31…if they are single categories and if they are parent categories. It will also remove all child categories of them if they have any.
Final disclaimer…I have only done a quick test of this…but it seems to work okay.
Hope that this helps.
Hi everyone, Please I need help I want to do this: display categories > click display subcategories > click display list of products > click display detail of product
I have:
index
{exp:weblog:categories weblog="{my_weblog}" parent_only="yes"}
<li><a href="http://{path={my_templet_group}/category}">{category_name}</a>
{/exp:weblog:categories}
categories
{exp:subcategories weblog="{my_weblog}"}
<li><a href="http://{path={my_templet_group}/subcategory}">{category_name}</a>
{/exp:subcategories}
subcategory
{exp:weblog:entries weblog="{my_weblog}"}
<li><a href="http://{url_title_path={my_templet_group}/detail}">{title}</a>
{/exp:weblog:entries}
detail
{exp:weblog:entries weblog="{my_weblog}"}
{name}
{description}
{/exp:weblog:entries}
this code is working fine when Im displaying categories> click>displaying subcategories > click> And here I should get a list of product withing this subcategory, but instead I have all products in subcategories displayed. when I modify code subcategories with adding category=”18” is working properly
{exp:weblog:entries weblog="{my_weblog}" category="18"}
<li><a href="http://{url_title_path={my_templet_group}/detail}">{title}</a>
{/exp:weblog:entries}
What I should put there, its like not reading in which category/subcategory we are…Its almost working Thank you
Hi combinedmedia,
If I understand you correctly, you basically want to know how to get the category group number, and put it into the sub-category “weblog:entries” tag so it only displays entries in that sub-category.
The approach I would take is using the {segment_x} tag. For example:
categories
{exp:subcategories weblog="{my_weblog}"}
<li><a href="http://{path={my_templet_group}/subcategory}{category_id}">{category_name}</a>
{/exp:subcategories}
This should output a link something like this : http://www.mydomain.com/index.php/my_template_group/subcategory/18
You can then grab the category_id number and stick it into your weblog:entries tag:
{exp:weblog:entries weblog="{my_weblog}" category="{segment_3}"}
<li><a href="http://{url_title_path={my_templet_group}/detail}">{title}</a>
{/exp:weblog:entries}
Note that I didn’t actually test this code, but it should be okay.
Hope this helps.
Cheers.
Hi agun Thank you for reply, unfortunately this is not working… when you have list of subcategories and you click on one of them its showing this page:
and its empty so maybe I also have mistake in subcategory code:
{exp:weblog:entries weblog="{my_weblog}” category=”{segment_3}”} <li>{title} {/exp:weblog:entries}
Maybe Im using bad approach? Maybe I should do it different way. I just don understand how I can display a list of entries of subcategory, depends which subcategory you choose
I got it working Maybe somebody will look for this code so I will put it here: I have index, that is displaying categories and subcategories.While you cliking on different subcategories there are displaying titles of entires from choosen subcategory
{exp:weblog:categories weblog="product2" parent_only="yes" style="linear" }
<h4>{category_name}</h4>
{embed="basel/_embed_child_query" my_parent="{category_id}"}
{/exp:weblog:categories}
----------------------------------------
{exp:weblog:entries weblog="product2"}
<ul>
<li><a href="http://{url_title_path=products2/detail}">{title}</a></li>
</ul>
{/exp:weblog:entries}
Titles of entires are linked to a page detail that shows full entry:
{exp:weblog:categories weblog="product2" parent_only="yes" style="linear" }
<h4>{category_name}</h4>
{embed="basel/_embed_child_query" my_parent="{category_id}"}
{/exp:weblog:categories}
----------------------------------------
{exp:weblog:entries weblog="product2"}
{name}
{description}
{/exp:weblog:entries}
we also need this code I took from wiki, I have created a new template group called basel and template called _embed_child_query:
<ul>
{exp:query sql="SELECT cat_id as child_category_id, cat_name AS child_category_name FROM exp_categories WHERE parent_id='{embed:my_parent}' "}
<li><a href="http://{path=products2/C{child_category_id}}">{child_category_name}</a></li>
{/exp:query}
</ul>
if you know better solution or different please post it Thank you
Hi,
I have published a new plugin, called “Child categories”.
It has similar purpose as Subcategories plugin - to display a list of subcategories for a given category, but more extended functionality.
“Child categories” plugin allows not only to display a list of subcategories, but also a list of entries posted to subcategories. It also allows to display subcategories of several parent categories and allows various types of ordering of subcategories and entries.
It is possible to display subcategories by specifying their parent categories or by specifying subcategory (in this case plugin will find parent category and other subcategories).
Hi there,
This plugin has really saved me, but the template_path var fell short. I’m using category url_titles on these pages, and looking up their IDs in the template. Linking each using template_path worked fine, but I needed to build my own links to /subcat/{category_url_title}.
I did this with the following two tweaks to your plugin:
$sql = "SELECT cat_id, cat_name, cat_url_title
FROM exp_categories
WHERE exp_categories.parent_id = '".$DB->escape_str($this->get_root_node())."' ";
//parse category_url_title variable
if ($key == 'category_url_title')
{
if (isset($row['cat_url_title']))
{
$tagdata = $TMPL->swap_var_single($val, $row['cat_url_title'], $tagdata);
//$tagdata = str_replace("/", "/", $tagdata);
}
}
Perhaps those can be included in your next release?
Thanks again.
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.