Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-01-16 22:43:36

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

smd_parent: grab parents up the tree from any category

After a discussion on parent categories the consensus was there was no easy way to get a parent from the current category. A short while later there was :-)

smd_parent takes the exact same attributes as <txp:category /> with a couple of extra options to allow you to grab any level parent category from the tree instead. Works with all category types; image, article, link… the plugin help has some tables to explain how it works.

Revision history
————————

All available versions and changes are listed here. Each entry indexes the relevant post(s) in this thread to learn about the features.

  • 15 Jan 08 | v0.1 | Initial release

Last edited by Bloke (2009-04-11 21:13:20)


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

Offline

#2 2008-01-17 00:40:20

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

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

Thanks, Stef. Am using it with much gratitude! :-)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#3 2008-01-17 01:02:00

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

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

Just had another look at your expanded help file in smd_parent.

Wow, I only now realize the full potential of this plugin. It is even more useful and powerful than I first imagined.

As your help file shows, you could make very extensive databases showing the full taxonomy (how an entry relates to the category tree) of each item. For example, you can now use Textpattern to make a database of animals, and for each animal show its full (linked!) Linnaean taxonomy in the individual article.

Just imagine the possibilities for scientific or commercial sites. Especially highly organized catalogues of items or products.

You have just pushed Textpattern a few steps up the ladder.

Sweet. Really sweet!

Last edited by Kjeld (2008-01-17 01:04:16)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#4 2008-01-17 17:29:33

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

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

*grin* thanks Kjeld, really glad it’s useful for you.

You know what was crazy: the initial hunk of code was a rip of the attribute-handling and error-checking code from <txp:category /> and the cat1/2 derivatives in the core.

Without that, handling the two extra options was about 8-10 lines of code; the rest of the functionality I palmed off to txp:category. So for a mod to the core it’d be about that sort of magnitude (maybe less) to add a parentlevel attribute do the same thing in each of the built-in category functions.

Perhaps I should find out how to submit this as a patch instead of a plugin?!


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

Offline

#5 2008-01-17 19:47:14

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

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

Bloke wrote:

Perhaps I should find out how to submit this as a patch instead of a plugin?!

Yes!

Offline

#6 2008-04-28 09:44:16

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

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

Very useful to be able to be able to associate a product to a brand (the latter being the parent).

Bloke, the link to the plugin isn’t working.

Anyone else have it handy?

Thanks!

Loz

Offline

#7 2008-04-28 10:01:08

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

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

lozmatic wrote:

Bloke, the link to the plugin isn’t working.

Works for me now, but I’ve noticed my hoster’s having a go-slow today. Sorry for any inconvenience.

Last edited by Bloke (2008-04-28 10:01:29)


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

Offline

#8 2008-04-28 10:20:11

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

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

I’m still getting an error. I’ll try later from home – thanks

Offline

#9 2008-04-28 10:30:34

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

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

lozmatic wrote:

I’m still getting an error. I’ll try later from home – thanks

Curious. What error are you getting?

How about from pastebin ? (I’ve set it to expire today so be quick!)


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

Offline

#10 2008-04-28 12:04:29

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

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

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.

No worries – I’ll try from home later today.

Thanks for your help.

Offline

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

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

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.

Hire 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: 12,476
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.

Hire 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

Board footer

Powered by FluxBB