Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2008-04-28 15:23:58

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

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

Well, now the world is waiting for the ‘grab children’ feature.
(No, I did not test smd_parent yet but posted it to d.i.u to remember)

I was also always wondering why the parent/children issue is not solved somehow in TXP core. If I remember right txp:breadcrumbs is the only core tag supporting the category branches.

And before somebody starts to build ‘big trees’: Are there maybe database issues with duplicate category name conflicts? (UK >> Coventry >> Parks >> Bloke, DE >> Hamburg >> Parks >> Bloke)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#14 2008-04-28 16:11:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

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

merz1 wrote:

Well, now the world is waiting for the ‘grab children’ feature.

Hehehe. If you can define what you’d like it to do and there’s no other pluign out there that does it, I’ll build it.

Are there maybe database issues with duplicate category name conflicts? (UK >> Coventry >> Parks >> Bloke, DE >> Hamburg >> Parks >> Bloke)

In theory there are no problems because it’s a balanced binary tree so each leaf is — in effect — the ‘sum’ of its branches. As long as you were to put new nodes directly under another, then duplicate names should be able to exist (I may be wrong here — someone please correct me if so).

TXP however, does not allow duplicate category names. Technically they are IDs; categories can be given any Title you like even if it already exists, but it might cause confusion unless you call them all “Bruce” to keep things clear :-D

I suspect it is because categories are always inserted at the root of the tree until you subsequently move them to a lower level (a bit of a pain for those, like me, who heavily use category hierarchies — I hope Crockery addresses this).

Often I want multiple categories with the same name (e.g. downloads for each Artist on my record label). Ideally I’d like either:

  • Downloads
    • Artist1
    • Artist2
  • Artwork
    • Artist1
    • Artist2

OR

  • Artist1
    • Downloads
    • Artwork
  • Artist2
    • Downloads
    • Artwork

I cannot realise either of these scenarios uniquely and have to do this when assigning them category names:

  • Downloads
    • Artist1_dld
    • Artist2_dld
  • Artwork
    • Artist1_art
    • Artist2_art

OR

  • Artist1
    • Downloads_art1
    • Artwork_art1
  • Artist2
    • Downloads_art2
    • Artwork_art2

It seems a shame to have to do that because if, for example, I rename an artist or a category I have to revist all sub-categories and rename them to keep them in line. If there was a true object-oriented interface to categories then Artist1->Downloads and Artist2->Downloads would be valid and unique.

It’s one of my little bugbears right now and if I ever get a chance I’d like to help build this type of hierarchy capability into xpattern’s core, since it plans to treat data as objects anyway. At the end of the day it’s just a way of organising ‘objects’ in a structured format.


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

Txp Builders – finely-crafted code, design and Txp

Offline

#15 2008-04-28 16:49:00

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

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

If you can define what you’d like it to do

Not now. Because of the category=ID thing (and not object = what a shame) and because of keeping information structure as flat as possible (but wiiiide :) I recently pushed children categories up the tree again :)

TXP however, does not allow duplicate category names.

Yep, that is really a hard coded burden (and a killer criteria against TXP for some).

At the end of the day it’s just a way of organising ‘objects’ in a structured format.

Wise letters arranged wisely.

<dream>A performing XML object oriented CMS is what we need riding on an XML database :)</dream>


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#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: 11,269
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.

Txp Builders – finely-crafted code, design and Txp

Offline

#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: 999
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: 11,269
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.

Txp Builders – finely-crafted code, design and Txp

Offline

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

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
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

Board footer

Powered by FluxBB