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

New "Subcategories" plugin available.

Development and Programming

Richard Frank's avatar
Richard Frank
200 posts
18 years ago
Richard Frank's avatar Richard Frank

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?

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

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?

       
Mikee Bee's avatar
Mikee Bee
179 posts
18 years ago
Mikee Bee's avatar Mikee Bee

@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?

       
Richard Frank's avatar
Richard Frank
200 posts
18 years ago
Richard Frank's avatar Richard Frank

thanks, I went with another solution, but that does look like it would work fine…

       
Ryan M.'s avatar
Ryan M.
1,511 posts
about 18 years ago
Ryan M.'s avatar Ryan M.

Has this thing ever been updated? My subcategories plugin reads “Copyright 2005”, and is version ‘Beta 2’. Now that 1.6 has the category_url_title field (among other new fields), I’d love to be able to pull that in as well.

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
about 18 years ago
Sue Crocker's avatar Sue Crocker

Ryan, MF hasn’t been around since the end of August. You might try contacting him directly.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
about 18 years ago
Ryan M.'s avatar Ryan M.

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! 😛

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
about 18 years ago
Sue Crocker's avatar Sue Crocker

So are you going to release your version? 😊

       
richhayler's avatar
richhayler
53 posts
about 18 years ago
richhayler's avatar richhayler

Please release the new version, it sounds like it is exactly what I am after.

Thanks 😊

       
RipeMedia's avatar
RipeMedia
62 posts
about 18 years ago
RipeMedia's avatar RipeMedia

Well, I found this thread, and went ahead and made the change for a ‘category_url_title’ field. I modified the Beta version # and the documentation.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 18 years ago
Lisa Wess's avatar Lisa Wess

Unfortunately, I am going to need to remove that attachment. The plugin is under Copyright, which means you’ll need MF’s permission to modify and distribute those changes. I highly recommend contacting him.

       
RipeMedia's avatar
RipeMedia
62 posts
about 18 years ago
RipeMedia's avatar RipeMedia

Sorry, I only posted because Sue was asking ‘mdesign’ to release his version, and didn’t mention this fact.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 18 years ago
Lisa Wess's avatar Lisa Wess

Well, you could post instructions for making that change; but not the actual file. =)

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

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.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
17 years ago
Lisa Wess's avatar Lisa Wess
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. =)

       
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.