Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2008-04-28 12:19:50

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,458
Website

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

lozmatic wrote:

pastebin.com returns a big fat ‘The Site requested is deemed to violate the Internet Security policy’. If I never post again it means the IT police here at work will have arrested me.

lol, off-topic but I’ve been behind one of those corporate firewalls myself. Amazing how much legitimate and useful stuff like pastebin they block trying to force people to stay focused which, in reality, does the opposite as people try to find ways round it (I can understand my site being off limits but pastebin is potentially useful in a business environment!)

I remember having my own proxy server running at home so any site that stopped us with the big fat “You are in violation of Corporate Instruction 75” guard dog, we could re-route.

btw, if they get you, I’ll vouch for your integrity :-)


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

#12 2008-04-28 14:17:45

lozmatic
Member
From: Melbourne, Australia
Registered: 2006-08-27
Posts: 259
Website

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

“You honour, Mr. Lozmatic didn’t actually want to grab his parents from up the tree… “

Offline

#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: 8,458
Website

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: Boston, MA, USA
Registered: 2006-10-04
Posts: 289
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: 8,458
Website

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

Board footer

Powered by FluxBB