Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2009-03-19 17:59:27

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: smd_parent: grab parents up the tree from any category

Thanks for this plugin! Just what I needed.

Offline

#17 2010-10-15 12:25:37

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: smd_parent: grab parents up the tree from any category

hey bloke, i’m having problems using this plugin, or maybe i’m not understanding how it works. my category structure is something like

-Animals
—Dogs
—-Chihuahuas
—-Labs
—Cats

I have 2 articles, one with the category “labs”, the other one with category “cats”.
I’m displaying them in the same form, where I call <txp:smd_parent catnum=“1” title=“1” level=“2” />
If I understand correctly, this should output “dogs” and “cats”, but instead I get “dogs” and “animals”

any clue what’s wrong?


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#18 2010-10-15 18:45:02

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: smd_parent: grab parents up the tree from any category

actually, I was wrong. It outputs “dogs” and nothing.

is there a way to get the same level on both?


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#19 2011-02-12 17:43:55

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: smd_parent: grab parents up the tree from any category

still having this problem, any insight?


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#20 2011-02-19 14:40:49

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,513
Website GitHub

Re: smd_parent: grab parents up the tree from any category

kemie wrote:

actually, I was wrong. It outputs “dogs” and nothing.

Hi Kemie, sorry for the ridiculous delay. I missed this first time round, thanks for the nudge.

The issue is that the pluign only outputs stuff “above” itself in the tree. Thus your first article, being a subcat of ‘Dogs’, displays Dogs. But your second article is actually ‘Cats’ and there is no category ‘above’ it at level 1. It is level 1. Thus it outputs nothing.

Depending on your viewpoint I suppose this could be considered a bug. Although I did mention it in the plugin help, I can’t for the life of me remember why I didn’t allow it to get the current level. Seems bizarre to have to make you decide beforehand whether you want to use this plugin or the built in category tags, especially since this plugin is just an extension to the category tag!

Try this. Edit the plugin code and find Line 35 which reads:

if ($reqLevel > 0 && $reqLevel < $currLevel) {

and swap it for:

if ($reqLevel > 0 && $reqLevel <= $currLevel) {

That’ll output the category if it’s the same level as the one given in the level attribute (or higher) in the tree. Not sure if that has any impact elsewhere but it works with my minimal testing.

Hope that helps. If it has no negative side effects I might make that the default behaviour in the next version. Thanks for highlighting it and sorry again for being so tardy in my response.

Last edited by Bloke (2011-02-19 14:42:17)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Online

#21 2011-02-19 18:20:50

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: smd_parent: grab parents up the tree from any category

Shame on you for providing tardy (and FREE) support for your wonderful (and FREE) plugin :).
Your fix seems to work perfectly. I didn’t do any extensive testing either, but it works in my case.
I guess it was a question of me misunderstanding the “level” variable, but I do think the change is a welcome one in any case.

Thank you so much! :)


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#22 2011-03-23 16:15:03

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: smd_parent: grab parents up the tree from any category

Is there any way to test the parent for multiple values? I currently have something like this:

<txp:variable name="parent_topic"><txp:smd_parent/></txp:variable>
[...]
<txp:if_variable name="parent_topic" value="x">Do this.</txp:if_variable>

I want to “Do this” if the parent category is X, Y, or Z, which I could enter as a comma-separated list. But if I’m not mistaken, if_variable can’t test for multiple values as of TXP 4.3.0.

Offline

#23 2011-03-23 16:17:50

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,513
Website GitHub

Re: smd_parent: grab parents up the tree from any category

johnstephens wrote:

Is there any way to test the parent for multiple values?

Not natively. smd_if’s in operator is probably your best bet. smd_multi_select is overkill.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Online

#24 2011-03-23 16:21:11

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: smd_parent: grab parents up the tree from any category

Thanks, Stef! I suspected smd_if might be the only way, but I thought I could get away with not installing another plugin. I’ll do it!

Offline

#25 2018-10-05 14:41:44

hildebruns
Member
Registered: 2009-03-10
Posts: 35

Re: smd_parent: grab parents up the tree from any category

Hello, is there a version for 4.7.1? I have the plugin installed and unfortunately it does not work.

Offline

#26 2018-10-05 15:08:08

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,513
Website GitHub

Re: smd_parent: grab parents up the tree from any category

Interesting. When you say “doesn’t work”, how are you using the tag and what do you expect? There should be nothing in the (very small) plugin that breaks under 4.7.x but there have been many changes to the parser and tags. Something may have affected my kludgy attempt at handling parents.

Depending on what you are trying to do, you may not even need the plugin any more as there have been tag improvements that might help out. So when we find out what it is you are trying to achieve with the plugin, someone may be able to help you find a native solution.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Online

#27 2018-10-05 15:54:03

etc
Developer
Registered: 2010-11-11
Posts: 5,690
Website GitHub

Re: smd_parent: grab parents up the tree from any category

In 4.7 <txp:breadcrumb /> can extract (grand-)parents from the category tree via limit and offset attributes:

<txp:breadcrumb category="your_category" limit="1" offset="-1"
    section="" label="" wraptag="" />

Also

<txp:if_category category="your_category" parent="1" name="cat1, cat2, cat3" />

will test if your_category is a child of cat1, cat2, cat3.

Offline

Board footer

Powered by FluxBB