Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2012-04-09 11:45:14
- mmelon
- Member
- Registered: 2006-03-02
- Posts: 95
nested category url structure
Hi,
I’ve been playing around trying to make this work. Categories have a parent<>child hierarchy so would seem to be candidates for structuring a website. Categories are content and don’t require higher permissions to create/change so are better in my eyes than sections to delineate structure.
I am trying to let cms operators create structured sites and have it reflected in the url so
shop
shop/sale
shop/sale/mens
etc
now I can set up the categories but I haven’t found a way to get the urls to play along
i can do
site.com/category/shop
and
site.com/category/shop/sale
but
site.com/category/shop/sale/mens
the third level is ignored. I think this is related to the fact that txp works with 2 categories out of the box.
If I could make the above work I imagine it shouldn’t be too hard to use a .htaccess rewrite rule to remove /category/ and job done.
With that not working i’ve tried various other techniques. gbp_permanent_links allows a category/title permalink style but can’t handle the nesting.
Then I tried smd_tags hoping that I could get tags/level1/level2/level3 working on the url but no dice.
I am thinking it might be a fairly simple* hack of the txpcore to get the category url structure I need, but am not sure.
*for a php dev
Anybody have any ideas?
Mike
Offline
Re: nested category url structure
mmelon wrote:
I can set up the categories but I haven’t found a way to get the urls to play along
No, they won’t. Parent->Child is just a convenience for the admin side organisation. Txp only has one category context at a time.
gbp_permanent_links allows a category/title permalink style but can’t handle the nesting.
I’ve seen it done, but I couldn’t tell you how unfortunately. Someone here knows, I’m sure.
Then I tried smd_tags hoping that I could get tags/level1/level2/level3 working on the url but no dice.
The current beta (on request only at the moment) can in fact do this — to a degree. But it might not be how you expect. The lowdown is that you can currently pipe-delimit tags to have it take any of them into account (i.e. find stuff that contains any of the tags) or you can plus-delimit them to find things that match all the tags.
The pipe and plus are hard-coded at the moment but I’m going to be looking into the feasability of making them configurable. This may open up the possibility to do:
site.com/tags/tag1/tag2/tag3
and have it mean either you want the tags to be cumulative (AND) or you want them to be combinative (OR). Depending on what you are trying to achieve neither of those may be suitable.
I may in fact add the option to permit you to decide that such multi-tag levels allow you to more easily offer drill-down capabilities. Building that structure as a set of drill-downable tags is something I have yet to explore with the tag suite. I suspect it’s possible to construct the system manually because you can override the ‘section’ when you link to tag landing pages so you could in fact tell it that the current “section” was the full URL (i.e. site.com/tags/tag1/tag2
) so that when you click tag3
it adds it to the URL rather than makes it into site.com/tags/tag3.
The <txp:smd_tag_list>
tag (among others I think) allows you to specify a parent label and so paves the way for you to be able to offer “up a level” navigation. Also, the ‘paren’t attribute allows you to start a tag list at a designated parent tag so you might be able to get the current tag and use that as a parent when drilling down the child lists.
As I say, none of this is tested and I don’t know how successful it would be — it all depends on whether I can get the delimiters to work with a slash. Watch the plugin thread to find out.
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
#3 2012-04-09 16:07:02
- mmelon
- Member
- Registered: 2006-03-02
- Posts: 95
Re: nested category url structure
Thanks for the reply Stef. I will keep an eye on the thread.
Offline
Re: nested category url structure
mmelon wrote:
Categories have a parent<>child hierarchy so would seem to be candidates for structuring a website. Categories are content and don’t require higher permissions to create/change so are better in my eyes than sections to delineate structure.
Hi Mike
I know it doesn’t really fit with your requirements, but the Textpattern Semantic Model suggests that categories aren’t really meant for creating structure.
And having tried to bend Txp more than a few ways to create > 2 levels of IA I can also say that – while it can be done using categories – it’s not the most practical approach. The pne I’ve settled on uses adi_menu (to create the illusion of subsections in the Write tab section drop-down) and some heavy action with gpb_permanent_links.
There’s some black magic involved in using that plugin that I’m at a loss to explain and it’s not well documented or supported. Graeme began to rewrite it a couple of years back, but I’m not sure that it will ever emerge.
Having said that, I’ve always managed to find a way to make the existing version do what I want – with some trial and error with the precedence settings you could use it for double categories I’m sure.
If you can’t make it work then smd_tags might be the way to go…
Offline
Re: nested category url structure
Bloke wrote:
The pipe and plus are hard-coded at the moment but I’m going to be looking into the feasability of making them configurable.
Done. And it works with a slash too.
Additionally, the plugin now has an option to turn the combinator capability on or off. Thus you can do:
site.com/tags/tag1/tag2/tag3
and have it mean one of:
- smd_related_tags: find items with tag1 OR tag 2 OR tag3
- smd_related_tags: find items with tag1 AND tag 2 AND tag3
- smd_related_tags: find items matching tag3 (smd_tag_list: consider tag3 as the one to list)
So depending on the settings you can do some pretty cool URL wrangling and searches. Bit more work on this part yet, but so far it’s going well.
Last edited by Bloke (2012-04-10 15:50:32)
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
Pages: 1