Hi all
The subcategories plugin looks good; it outputs the child categories of a given “root_node” (parent category) as promised. However, I can’t link to the category.
My previous code looked like this:
{exp:weblog:categories weblog="news" style="linear"}
<li><a href="http://{path=dialogue/events}">{category_name}</a></li>
{/exp:weblog:categories}
Although I saw the whole tree from the highest parent to the lowest child, at least it linked to the category (automatically appended /category/category_name)
The new code currently looks like this:
{exp:subcategories root_node="16"}
<li><a href="http://{path=dialogue/events}">{category_name}</a></li>
{/exp:subcategories}
but it links to the “dialogue/events” template with no category_name appended.
I use category names. Is there any way around this?
Hi,
I am using this plugin to display my subcatogries.
I would like to do the following:
When there are no subcategories in the root_node, there need to be the text “empty”
{exp:weblog:categories weblog="{embed:weblog}" parent_only="yes" style="linear" show="not 15"}
{exp:subcategories root_node="{category_id}"}
{if subcategories_count < 1}empty{/if}
{/exp:subcategories}
{/exp:weblog:categories}
Now it displays empty at the categories that have subcategories. The categories without subcategories displays nothing.
Can someone help me?
@Richard Frank
Do you mean that the url isn’t getting the category_name added to the end?
You could add it to the url manually.
Like this…
{exp:subcategories root_node="16"}
<li><a href="http://{path=dialogue/events/{category_name}}">{category_name}</a></li>
{/exp:subcategories}
See if that works?
Thanks, Sue. I modified my version to pull in that new field - but I ended up going another direction entirely based on a suggestion I saw Boyink post elsewhere about just using a relationship to work as a “bucket” rather then using (sub)categories.
EE is almost too flexible sometimes! 😛
I knew I couldn’t post my modified file - because I’ve been caught by Lisa once before and I learned my lesson! Take note RipeMedia, that you can’t modify files and redistribute like that - unless you ask permission from the author. The best way to get something updated is to make the mods, tell the creator/author what you did, and have them update the “official” release. That way there aren’t a zillion slightly different modifications out there and things stay nice and tidy for everyone.
That said, here’s all one has to do to modify the existing subcategories plugin to add category_url_title:
Add “cat_url_title” to the sql around line 291.
$sql = "SELECT cat_id, cat_name, cat_url_title, cat_description, cat_image, cat_order
FROM exp_categories
WHERE exp_categories.parent_id = '".$DB->escape_str($this->get_root_node())."' ";
Add the following to the “parse single variables” area around line 358.
//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);
}
}
It’s been a few days since I did that, so I might have forgotten something, but I think that’s it.
I knew I couldn’t post my modified file - because I’ve been caught by Lisa once before and I learned my lesson! Take note RipeMedia, that you can’t modify files and redistribute like that - unless you ask permission from the author.
You know I wuvya, Ryan.
That said - it’s not an all-out rule; it depends on the license. If the top of that pretty file says “GPL” or another such license, then you can modify/redistribute it under those terms. But if it says “Copyright” - then you must respect that, too.
Just wanted to clarify; I did check MF’s file before I removed the attachment. =)
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.