Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-07-11 19:10:11

jrgip
Member
Registered: 2006-04-19
Posts: 12

if BOTH category1 and category2

I want to display certain content only if it is in both category1 and category2. I tried nesting an if_category inside an if_category and it did not work. How can I accomplish this?

jon guip

Offline

#2 2006-07-11 19:54:26

NyteOwl
Member
From: Nova Scotia, Canada
Registered: 2005-09-24
Posts: 539

Re: if BOTH category1 and category2

I haven’t tried it but how about something like . . .
<br />

<code>

<txp:if_article_category name=“Widgets”> // check for first category

<txp:if_article_category name=“Gadgets”> // check for second category

// do whatever if both are true here

<txp:else /> // if second category is false

// do whatever if only the first is true here

<txp:if_article_category> // close check for second category

<txp:else /> // if first category is false

<txp:if_article_category name=“Gadgets”> // check for second category

// do whatever if only the second is true here

<txp:else /> // if second cat is false

// do whatever if neither are true here

</txp:if_article_category> // close check for second category

</txp:if_article_category> // close check for first category

</code>

<br />
Of course remove the // lines :)

It might be easier to do with some php but I tried to stick with txp tags.


Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;

Offline

#3 2006-07-11 20:10:59

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: if BOTH category1 and category2

Can’t nest the same tags, unfortunately.

Offline

#4 2006-07-11 20:17:32

jrgip
Member
Registered: 2006-04-19
Posts: 12

Re: if BOTH category1 and category2

I guess that’s why it would break. I guess php is an option but are both the categories accesible through a global variable at the form level? I have had mixed results accessing the article array. It seems that it is only accessible at certain points in the page rendering process. I am essentially trying to set up a three tierd navigation system where one category is recognized as a sub of another. It seemed the easiest way would be to simply check to see if both categories were assigned to an article and then render that content. Thanks.

Offline

#5 2006-07-11 20:25:58

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: if BOTH category1 and category2

They are available from within an article form:

<txp:php>

global $thisarticle;

if ($thisarticle['category1'] and $thisarticle['category2'])
{
	// echo your content here
}

</txp:php>

:)

Offline

#6 2006-07-11 21:10:30

jrgip
Member
Registered: 2006-04-19
Posts: 12

Re: if BOTH category1 and category2

Thanks Mary! That should work out well.

Offline

Board footer

Powered by FluxBB