Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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
2. Category 2
  • first article
  • second article
  • third article
3. Category 3
  • 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

#2 2010-10-12 11:51:47

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

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

#4 2010-10-12 13:03:43

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

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

#6 2010-10-12 15:02:05

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#7 2010-10-12 15:10:47

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

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

#13 2011-01-18 20:01:46

ricoschette
Member
From: Estonia
Registered: 2005-09-17
Posts: 176

Re: Need to display different categories with articles inside on one page

Anyone want to make quick 15€?
Will transfer through PayPal any time.

Can’t wrap my mind around it myself.

Just need the code above to work with “rss_unlimited_categories” (or is there any better option?).

Offline

#14 2011-01-18 20:16: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, you’d better post in the plugin thread then, because over there your post will be noticed by people who are familiar with the plugin sooner than here.

Offline

#15 2011-01-18 20:54:02

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

Re: Need to display different categories with articles inside on one page

ricoschette

You probably have this part down, but just in case it helps —

unlike a lot of plugins that replace the regular txp tags with their own version, and extra features, rss_unlimited_categories is not a 1 for 1 replacement of txp:category tags.

rss_unlimited_categories creates a parallel category data set. (i.e. it uses its own database table of categories instead of txp’s categories.) You will need to re-create your categories in rss_uc and then associate your articles accordingly.

Thus, the txp:category tags cannot access the rss_uc data. And visa-versa. rss_uc tags can’t access txp:category data. I’m not positive, but would expect this to be true of the conditionals (txp:if_category), which would be looking in the txp:category data.

There are some comparable tags, but, again, as you probably know, they are not interchangeable, and IIRCC, not every txp:category tag has a rss_uc counterpart. (Example, I don’t think there are rss_uc conditionals, but I could be mistaken).

rss_unlimited_categories_article_list will help recreate the lists you are after, and has a section attribute as well (you mentioned that in previous post). So I’m guessing that will be the workhorse in what you are trying to accomplish.

fwiw, smd_tags is sort of 1/2 way between rss_unlimited_categories, and tru_tags. Tags can be associated to txp:categories. Perhaps it might be an alternative if rss_uc can’t do what you are after . . . .

Offline

Board footer

Powered by FluxBB