Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How do I detect I am on a category list page?
I assume that this has to be done within the default page template. But for the life of me, I don’t see any txp tags to test if I am on a category list page.
I use <txp:category_list> to generate a list of links on my section pages and on my article pages. I use categories like tags – to me they are references that point to a list of articles and which have friend /category/fruit URLs. When the user clicks on those category links I want to take them to a category page which shows all the articles (limit 10 with prev/next links sorted recently) that are of that category.
How can I pull this off in Textpattern?
How can I get rid of that silly category friend URL: http://www.mysite.com/category/fruit
This seems so unnatural to me and to the user. Category is implicit in all of this. Why does textpattern put ‘category’ in the actual URL path? I also hesitate to extrapolate and say, what is so different about sections versus categories? I would think both should be the same and that the word section should be “category” and categories should have subcategories and reference page templates.
Someone educate me please on this issue as from an SEO/information architecture standpoint, this seems very unnatural. The flow and logic in the default template, for example, just seems so odd to me. This stuff should just cascade down to template defaults.
Last edited by kkobashi (2008-08-07 03:29:42)
Kerry Kobashi
Kobashi Computing
Offline
Re: How do I detect I am on a category list page?
Start here: <txp:if_category />. BTW, sections aren’t silly. Trust me.
Offline
Re: How do I detect I am on a category list page?
Offline
Re: How do I detect I am on a category list page?
I’ve switched to rss_unlimited_categories and have general success using it. The only problem I have is the following with the breadcrumb and categories:
txp:breadcrumb outputs something like this: Home >> Category >> Fruit
The link to Home is: http://www.site.com/
The link to Category is: http://www.site.com/Category
The link to Fruit is: http://www.site.com/Category/Fruit
Now when I click on the Home link it goes to the right place.
When I click on the Fruit link, some bit of magic happens behind the scenes. If one has a section named ‘category’, it will be taken to the page associated with it. However, if you don’t have a section named ‘category’, you are taken to the default page. This is all fine. But nowhere does it say in the documentation that you need to setup a category section. It seems there is some hardwired assumptions being made on the word ‘category’. True?
Now, when I click on the Category link, I get a 404 error.
Is the breadcrumb correct in putting Category text in the output? A category is not a section. I am now forced to turn off breadcrumb links to avoid spiders and users clicking on the Category link to raise a 404 error. I really would like to find out how to get around this issue.
Last edited by kkobashi (2008-08-09 07:59:35)
Kerry Kobashi
Kobashi Computing
Offline
Re: How do I detect I am on a category list page?
Well it looks like there is some sort of weirdness going on if you actually use the word ‘Category’ as a section. I’ve since changed the section name to “Tags” and although I got rid of the error with the http://www.site.com/Category problem not bringing up a 404, I now get an error when I click on Fruit. When I hover over the link it says:
http://www.mysite.com/category/Fruit and heads right back to the default page. Ugh.
Last edited by kkobashi (2008-08-09 08:48:26)
Kerry Kobashi
Kobashi Computing
Offline
Re: How do I detect I am on a category list page?
A few default routes are built into Textpattern which won’t work as section names, namely (as you’ve noticed) /category/
(language-dependent), plus /rss/
, /atom/
, /file_download/
, /section/
(language-dependent), and /author/
(language-dependent).
Offline
Re: How do I detect I am on a category list page?
Then there is a bug in the breadcrumb that needs to be fixed. Clicking on “category” results in a 404.
Last edited by kkobashi (2008-08-09 16:19:58)
Kerry Kobashi
Kobashi Computing
Offline
Re: How do I detect I am on a category list page?
Thanks for mentioning this, but <txp:breadcrumb />
is actually quite well.
Maybe you’d rather follow the advice given here and refrain from using reserved routes like “category” for section names?
Offline