Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-14 08:58:03

vasile33
New Member
From: Bucharest, Romania
Registered: 2005-08-30
Posts: 3

if_category:Can I force TXP to accept another tag as a value for name?

Hello everybody,

Still a beginner… I’m building a website with 6 different sections and articles in each section have category1 &category2 assigned. I control the displayed articles by selecting the section or category1 or category2. Basically I want to achieve the following behavior:

- When the section is selected I want to display the articles with a small header containing the category1 & category2 for each article (Ex: Category: category1 name | Sub-Category: category2 name).<br />

- When category1 is selected the header will contain only the category2 name.<br />

- When category2 is selected the header will not be displayed.<br />

I tried to do this by using something like this:

<code><txp:if_category name=”<txp:category1 />”> Display: Category2 name
</txp:if_category></code>
<code><txp:if_category name=”<txp:category2 />”> Display: nothing
</txp:if_category>

…but it is not working. The name attribute seems to accept only strings and not other TXP tags… Any suggestions how to do this automatically?

I manage to obtain the desired result by using mdm_if_category plugin and manually feeding with all categories names separated by commas.

Regards,
Vasile

Last edited by vasile33 (2005-11-14 13:03:50)

Offline

#2 2005-11-14 16:48:03

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: if_category:Can I force TXP to accept another tag as a value for name?

This needs moving to “How Do I” forum.

I’m not sure about this as you are mixing article form and page tags but if the plug-in works and you are using 4.0.2 you can do the same comma-separated list with the TXP tag so no need for the plug-in. It may also be a problem with where you have the code. If it is above the article it may not know what the article category is as opposed to being below the article where it will know the article category though don’t quote me on that. ;)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2005-11-14 17:14:35

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: if_category:Can I force TXP to accept another tag as a value for name?

I don’t think the parser can see a nested tag that way, the tag is passed as text inside the function without being processed for its value. That way you never get a category match to an exsiting category.

You will probably get a better response over at How Do I…

Offline

#4 2005-11-14 17:39:05

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: if_category:Can I force TXP to accept another tag as a value for name?

This has been discussed before:

tags-in-tags

Offline

#5 2005-11-15 01:04:20

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: if_category:Can I force TXP to accept another tag as a value for name?

An inventive shuffle of the following article based tags might be what you are looking for, these also take a category attribute. <a href=“http://textpattern.net/wiki/index.php?title=Txp:if_article_category”>Txp:if_article_category</a>
Anytime that you reference cat1 or cat2 as levels you will be dealing with specific articles.
<code>
<txp:if_article_category number=“1”>
Category1
<txp:else />
NO Cat
</txp:if_article_category>
<txp:if_article_category number=“2”>
Category2
<txp:else />
NO Cat
</txp:if_article_category></code>

Offline

#6 2005-11-15 06:38:06

vasile33
New Member
From: Bucharest, Romania
Registered: 2005-08-30
Posts: 3

Re: if_category:Can I force TXP to accept another tag as a value for name?

Stuart: I upgrade TXP and from now on I’ll use the normal TXP tag. Thanks!

Spencer: thank you for clarifying this!

Rsilletti: your code work like a charm. Many thanks!

Vasile

Last edited by vasile33 (2005-11-15 06:39:07)

Offline

Board footer

Powered by FluxBB