Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-06-25 17:59:56
- matthijs
- Member
- Registered: 2008-12-15
- Posts: 32
Which page and tags are used to display categories
When using the tag
<txp:category_list parent=“somecategory” break=“li” wraptag=“ul” />
It will show a list of categories, linked in a list. The links will go to
/category/{categoryname}
/category/{anothercategoryname}
However, what “page”/template is used to display the content once you visit one of those links? So the URL you visit on the site is
mysite.com/category/categoryname
Now which page/template is being used/rendered, and what txp tags can be used to show content (be it another list of articles within that category or just the articles them selves)?
Offline
Re: Which page and tags are used to display categories
Which ever page is set to be used by your default section.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
#3 2009-06-25 20:51:00
- matthijs
- Member
- Registered: 2008-12-15
- Posts: 32
Re: Which page and tags are used to display categories
But that’s my home page. The default section uses/displays the home page.
I don’t want that, I need some page/template to show the categories and category lists. Isn’t that possible?
Offline
Re: Which page and tags are used to display categories
matthijs wrote:
I don’t want that, I need some page/template to show the categories and category lists. Isn’t that possible?
By opening the categories to different section. See category_list
’s attribute called section
. After that you can use the template assigned to that section.
Other way is nest some <txp:if_category>
tags to modify the default
section & page.
Offline
#5 2009-06-25 21:41:53
- matthijs
- Member
- Registered: 2008-12-15
- Posts: 32
Re: Which page and tags are used to display categories
I’m really sorry, but that is totally confusing. Where should I put that category_list tag? In which page/template?
Offline
#6 2009-06-25 22:09:49
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Which page and tags are used to display categories
<txp:category_list /> displays a list of links to your category pages. And a ‘category page’ is a page with a list of articles in a particular category.
So place <txp:category_list section="your-section" />
on whatever page you want the list to appear.
In this example the ‘category page’ is a page in your section ‘your-section’, so you need to have a <txp:article /> tag on your page template for section ‘your-section’ to display the list of articles. Note that, in order to be displayed, the articles also need to be in section ‘your-section’.
Having said that, I think that if you first try and follow this tutorial you will gain a better understanding of how Txp works.
Offline
#7 2009-06-26 06:21:02
- matthijs
- Member
- Registered: 2008-12-15
- Posts: 32
Re: Which page and tags are used to display categories
I’m really glad with your help. But I’m afraid we’re misunderstanding each other.
Getting the list of categories displayed is not the problem. I have that. The problem is after that: getting the list of articles within that category displayed. Let me explain it step by step. I have:
Section: projects
Page: projects
Section: project-archive
Page: project-archive
Category: projects
child categories of category projects: castles, houses, farms, etc
A few articles, put in section projects and with a child category like castles
Now what I want to do is this:
1. Visiting the URL /projects-archive/
shows a list of the links to child categories of projects (castles, houses, farms, etc)
<a href=”/category/castles/”>castles</a>
<a href=”/category/houses/”>houses</a>
This, I accomplished by using
<txp:category_list parent=“projects” break=“li” wraptag=“ul” />
inside the page/template project-archive. Simple enough
Clicking one of these links, say the castles, leads you to:
2. Visiting the URL /category/castles/
shows a list of the articles with category castles
-> this is what I am asking about now, which I am not able to have displayed
<a href=”/projects/castle-one/”>castle one</a>
<a href=”/projects/castle-two/”>castle two</a>
..
now clicking one of these links, say castle-one, leads you to:
3. Visiting the URL /projects/castle-one
This is just a display of the single article / project
Els: I did follow that tutorial already, I perfectly understand what is in there. I know what sections, pages, forms, etc are and how they interact. It’s just that knowing which tags can be used where, and what they display, in which situations is very unclear. And the manual pages don’t help there either. I am an experienced web developer, programming PHP for a few years, I have been building sites with many CMS systems. But the txp tag system is just very confusing. In one case a tag is just an echo of something. Another tag might be more a sort of function. but depending on where you use it or other circumstances it does something else, etc
Offline
#8 2009-06-26 09:56:20
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Which page and tags are used to display categories
<txp:article_custom category="castles" section="castles">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
Put this where you want your list of articles to appear. (Don’t know if you actually have a section castles.)
article_custom can be finetuned extremely well.
Last edited by uli (2009-06-26 09:56:40)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#9 2009-06-26 13:20:39
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Which page and tags are used to display categories
matthijs wrote:
1. Visiting the URL /projects-archive/
shows a list of the links to child categories of projects (castles, houses, farms, etc)
<a href="/category/castles/">castles</a>
<a href="/category/houses/">houses</a>
This, I accomplished by using
<txp:category_list parent="projects" break="li" wraptag="ul" />
inside the page/template project-archive. Simple enough
Just a note: you could generate links like /projects/?c=castles by adding section="projects"
to your category_list tag. Depending on whether you are going to use the section
attribute or not, you will have to place your article or article_custom tag(s) on either the ‘default’ page template or the page template for section ‘projects’.
2. Visiting the URL /category/castles/
shows a list of the articles with category castles
-> this is what I am asking about now, which I am not able to have displayed
<a href="/projects/castle-one/">castle one</a>
<a href="/projects/castle-two/">castle two</a>
Yes, I understand that is what you want, and there are several posts (also in your other thread) saying you need an article tag (<txp:article />
or <txp:article_custom />
) to display your article list.
Expanding Uli’s example:
If you are not going to add the section="projects"
attribute to the category_list tag, the list of articles in a particular category will be displayed on the front page, so something like this should be placed on your page template for section ‘default’:
<txp:if_category>
<!-- this is page /category/category-name -->
<txp:article_custom section="projects" category='<txp:category />' wraptag="ul" break="li">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
<txp:else />
<!-- this is the actual front page -->
<txp:article /><!-- or whatever you want here -->
</txp:if_category>
and on your page template for section ‘projects’ a simple article tag (<txp:article />
) will do (you can add the attributes you need of course).
If you follow my example and add section="projects"
to the category_list tag, the list of articles in a category will be displayed on section page ‘projects’, and you’ll need to place something like this on your page template for section ‘projects’:
<txp:if_individual_article>
<!-- this is page /projects/article-title -->
<txp:article form="your-individual-article-form" />
<txp:else />
<txp:if_category>
<!-- this is page /projects/?c=category-name -->
<txp:article_custom section="projects" category='<txp:category />' wraptag="ul" break="li">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:if_category>
</txp:if_individual_article>
But the txp tag system is just very confusing.
It is not :) but it can take a while before you realize that. Ask anyone here how it felt being new to Txp :)
Offline
#10 2009-06-27 16:26:06
- matthijs
- Member
- Registered: 2008-12-15
- Posts: 32
Re: Which page and tags are used to display categories
Thanks for your help.
@Ulie: your code would not work, as I can have more categories which I want to display. Not only castles.
Adding the code from Els did finally give me the list of articles within a category
<txp:if_category>
<!-- this is page /category/category-name -->
<txp:article_custom section="projects" category='<txp:category />' wraptag="ul" break="li">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
<txp:else />
<!-- this is the actual front page -->
<txp:article /><!-- or whatever you want here -->
</txp:if_category>
Only, turning on the debug mode shows me:
Tag error: -> Textpattern Notice: Page template home does not contain a txp:article tag on line 504
textpattern/publish.php:504 trigger_error()
index.php:33 textpattern()
Is that bad?
Anyway, as I understand now: requesting a category ( URL category/{somecategory} ) will “call/run” the default template. That is what I needed to know.
And as I understand as well, is that adding section=”{somesection}” to the txp:category_list will make a call to the somesection section with ?c={thecategory}
So I guess that for now my problem is solved. Thanks for all the advice so far. I’ll go play with the code some more to see if everything is working correctly now.
///
It is not :) but it can take a while before you realize that. Ask anyone here how it felt being new to Txp :)
It is! Sure, if you put in enough effort and learn every tag and trick there is, it becomes easier. But the system itself is much more difficult then say a comparable system like Wordpress. I build my very first website with WP many years ago, not knowing anything about HTML or PHP at the time, being able to customize everything pretty soon. I’ve been working with Txp on a site I maintain for over a year now, but what is the main difficulty of the custom tag system of txp is that the tags/tag system is not very intuitive. Maybe the naming is not very clear. And the fact that some tags are “context” sensitive while others aren’t, is not helping either. It’s not very intuitive to have a “function” do something else just because the “context” is different. But well, this all doesn’t matter. maybe one day I can make a proposal for a redesign/renaming of some tags ;)
Offline
#11 2009-06-27 16:50:20
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Which page and tags are used to display categories
matthijs wrote:
… as I can have more categories which I want to display. Not only castles.
Like I said: article_custom can be finetuned extremely well.
E.g. with more (comma separated) categories.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#12 2009-06-27 18:58:48
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Which page and tags are used to display categories
matthijs wrote:
maybe one day I can make a proposal for a redesign/renaming of some tags ;)
Maybe you will understand them then, but the rest of us will be just as confused as you are now… ;)
Offline