Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Subcategory URL
I am trying to implement the following URL structure /section/category/sub-category/
I had a quick play with gbp_permanent_links
, but as far as I can see it doesn’t allow for nested categories in the URL.
Does anyone have any experience with this?
Offline
#2 2010-02-01 00:32:59
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Subcategory URL
Don’t know if you could get it to work by using /section/category1/category2/? Of course in that case the parent should always be category1 and the subcategory category2…
(Aside: questions about plugins are better asked in the plugin thread.)
Offline
Re: Subcategory URL
Thanks Els—very true, I posted in the plugin thread as well now. However, I was wondering more whether there are any other solutions other than the gbp_permanent_links
.
The problem with category1 and category2 is that they only become 1 and 2 once they are applied to an article. It is pretty much irrelevant for category listings.
Last edited by dl33 (2010-02-01 00:48:09)
Offline
#4 2010-02-01 08:00:42
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Subcategory URL
dl33 wrote:
The problem with category1 and category2 is that they only become 1 and 2 once they are applied to an article. It is pretty much irrelevant for category listings.
Yes, I know, but that’s probably the reason why gbp_permanent_links won’t be able to handle this: it would somehow need to find the parent to an article’s category. Don’t know if you have many categories, but it might be possible to set up a permanent link rule for each category, and enter the parent as plain text.
Offline
Re: Subcategory URL
Something a little different: Is there a way to find out whether a category has any children?
I tried <txp:variable name="if_cat_children" value='<txp:category_list section="portfolio" parent='<txp:category />' wraptag="" break="," exclude='<txp:category />'><txp:category link="0" title="0"/></txp:category_list>'/>
, to then check whether the variable is empty—however, it always is empty even when it should contain the names of some subcategories.
Offline
#6 2010-02-01 23:51:48
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Subcategory URL
<txp:variable name="if_cat_children" value='<txp:category_list section="portfolio" parent=''<txp:category />'' wraptag="" break="," exclude=''<txp:category />''><txp:category link="0" title="0"/></txp:category_list>'/>
Try this (tags in tags in tags need two single quotes…). I don’t think the section attribute is doing anything in this code, so you may as well remove it.
Offline
Re: Subcategory URL
Thanks! Actually I just looked at your hasarticle txptip and saw the two ‘’ myself. Not entirely sure why, but it works…
Offline
Pages: 1