Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-10-12 10:44:25
- ricoschette
- Member
- From: Estonia
- Registered: 2005-09-17
- Posts: 176
Need to display different categories with articles inside on one page
I need to create a page structured like this:
3 column layout, where there’s categories on the left and news on the right column.
left content – middle content – right content
In the middle there should be all categories opened with articles under them:
1. Category 1- first article
- second article
- third article
- first article
- second article
- third article
- first article
- second article
- third article
and so on…
And when you choose from the left sidebar category list a category, only articles in that category will show up.
When choosing article from middle column, only that article will show up.
For article listing I have this template:
<p class=“names”><em><txp:permlink><txp:title /></txp:permlink></em> – <txp:custom_field name=“introtext” /></p>
What do you think TXP gurus?
How complicated is this?
Offline
Re: Need to display different categories with articles inside on one page
Hi
For middle column you may use txp:category_list like this
<txp:if_article_list>
<txp:category_list category="cat1, cat2,cat3">
<txp:category />
<txp:article category='<txp:category />' />
</txp:category_list>
<txp:else />
<txp:article />
</txp:if_article_list>
This only a simple exemple
Cheers
Offline
#3 2010-10-12 12:15:15
- ricoschette
- Member
- From: Estonia
- Registered: 2005-09-17
- Posts: 176
Re: Need to display different categories with articles inside on one page
OK, thanks.
Your example displays all categories, but all those categories have articles under them that belong to another category.
For example category 5 has 1 article, but this code displays all articles under category 5, too.
Anyway, I give you a link
This is category “Liha” (means “meat” in English).
And this is the page where all categories should come in the row: link
Offline
Re: Need to display different categories with articles inside on one page
Hum sorry the code must be
<txp:if_article_list>
<txp:category_list category="cat1, cat2,cat3">
<txp:category />
<txp:article_custom category='<txp:category />' />
</txp:category_list>
<txp:else />
<txp:article />
</txp:if_article_list>
My mistake is using txp:article instead of txp:article_custom
Cheers
Offline
#5 2010-10-12 14:24:37
- ricoschette
- Member
- From: Estonia
- Registered: 2005-09-17
- Posts: 176
Re: Need to display different categories with articles inside on one page
Thanks.
Modified it a bit, so when choosing category, it will only show that category and articles under it.
<txp:if_category>
<h1><txp:category title=“1” /></h1>
<txp:article listform=“article_listing_kaupmehed” form=“kaupmees” limit=“9” />
<txp:else />
<txp:if_article_list>
<txp:category_list category=“cat1,cat2,cat3”>
<txp:category title=“1” wraptag=“h1” link=“1” />
<txp:article_custom section=“kaupmehed” listform=“article_listing_kaupmehed” form=“kaupmees” limit=“9” category=’<txp:category title=“1” />’ />
</txp:category_list>
<txp:else />
<txp:article />
</txp:if_article_list>
</txp:if_category>
ONE more question.
How can I exclude unnecessary categories? I want only those categories to be shown that are for this section.
Not others.
And is it possible to not show empty categories?
Gotta love TXP and this community!
Last edited by ricoschette (2010-10-12 14:45:18)
Offline
Re: Need to display different categories with articles inside on one page
Check the TextBook listing for category_list
. There is an exclude
attribute for just this purpose.
Excluding empty categories is rather more involved. Best bet for a recipe is TXP Tips. You’d either need a plugin or some pretty elaborate code, using variable
and if_variable
along with article_custom
to check each category for existing articles.
Code is topiary
Offline
Re: Need to display different categories with articles inside on one page
Hi
you have <txp:category_list category=“cat1,cat2,cat3”> where only cat1,cat2,cat3 are used and no others, if you are talking about the left side of you site you can use exclude like Jeff told you.
And a notice: there is no relationship between categories and sections
Cheers
Offline
#8 2010-10-12 16:21:15
- ricoschette
- Member
- From: Estonia
- Registered: 2005-09-17
- Posts: 176
Re: Need to display different categories with articles inside on one page
Yes.
Yes, I’ve done left sidebar menus with exclude for different sections.
It’s just kind of annoying to write that long list form every page.
Anyway, we’ve reached for the solution and I thank you guys!
Offline
#9 2010-10-12 17:07:22
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Need to display different categories with articles inside on one page
ricoschette wrote:
category='<txp:category title="1" />'
This is wrong, the value should contain the category name, not the title. Suppose your category title is ‘My First Category’, the category name is probably ‘my-first-category’ in that case. Using the tag like you did will make it look for a category name ‘My First Category’, which doesn’t exist.
Offline
#10 2010-10-12 19:23:49
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Need to display different categories with articles inside on one page
Sure. Add a <txp:article status="sticky" />
just before the category_list tag.
Offline
#11 2010-10-12 20:34:53
- ricoschette
- Member
- From: Estonia
- Registered: 2005-09-17
- Posts: 176
Re: Need to display different categories with articles inside on one page
It works like a charm.
Thanks again!
Offline
#12 2011-01-10 10:25:17
- ricoschette
- Member
- From: Estonia
- Registered: 2005-09-17
- Posts: 176
Re: Need to display different categories with articles inside on one page
Could I please get a bit more help with implementing “rss_unlimited_categories” instead of TXP categories.
Right now I have this code:
———
<txp:if_category>
<h1><txp:category title=“1” /></h1>
<txp:article listform=“article_listing_kaupmehed” form=“kaupmees” limit=“9” />
<txp:else />
<txp:article status=“sticky” form=“asukoht” />
<txp:if_article_list>
<txp:category_list exclude=“avaleht-uudis,kalatoidud,kaupmees,leiunurk,parimad-pakkumised,pearoog,tore-ajaviide,turg,vaega-hea-retsept,vaerske-kaup,eelroog,supp,salat,suupiste,soolane-kuepsetis,magus-kuepsetis,pearoog-lihast,pearoog-kalast,pearoog-koeoegiviljast,lisandid,magustoit,hoidis,jook”>
<txp:category title=“1” wraptag=“h1” link=“1” />
<txp:article_custom section=“kaupmehed” listform=“article_listing_kaupmehed” form=“kaupmees” limit=“9” category=’<txp:category />’ />
</txp:category_list>
<txp:else />
<txp:article form=“kaupmees” />
</txp:if_article_list>
</txp:if_category>
———
How do I change it with rss_unlimited_categories?
Thanks!
Last edited by ricoschette (2011-01-10 13:09:41)
Offline