Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
if_category won't work
I posted here yesterday (topic <a href=“http://forum.textpattern.com/viewtopic.php?id=14840”>category not displayed</a>) and now I am starting again… I can’t get if_category to do the thing I want.
What I’m trying to achieve is this: display a compact menu when a group of example-articles is inactive, and display an extended menu when the link ‘examples’ is clicked.
So, the compact menu would look something like this:
- » introduction
- elaboration
- examples
And the extended menu would look like this:
- introduction
- elaboration
- examples:
- » example 1
- example 2
- example 3 etc.
I thought using if_category would help, but I tried (a.o.) this:
<code><txp:if_category name=“examples”> expanded menu <txp:else /> compact menu </txp:if_category></code>
<br />BUT! This always outputs the default option (i.e. ‘compact menu’). Even though I categorized the example-articles in ‘examples’. And I placed this in a page layout, so that should be working, right? I also tried to extract data from <code>$pretext</code> and <code>$article</code>, trying to put things together using <code><txp:php></code>-tags, but the category data do not seem to be passed. Am I wrong to think that it should be possible to get those data (like <code>$pretext[‘c’]</code>)? The only thing that does work is the <code>txp:category1</code>-tag in an article, but that one works only in an article and not on a page.
Help Very Much Appreciated!
Offline
#2 2006-02-23 11:36:57
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_category won't work
maica: please don’t create a new thread on the same issue a day later.
What are the contents of your page template? Make use of pastebin: paste your page’s code in it, and then post a link to it here.
Offline
Re: if_category won't work
Sorry, I did not mean to mess up the structure… :S
I put the code <a href=“http://txp.pastebin.com/568352”>here in pastebin</a>.
The default menu is the only one showing up, even when an article categorized as ‘examples’ is active. I am starting to think that my logic takes a wrong turn here…
By now I have hardcoded a php menu that does the job, specifying article id’s (the page has only static content). But I’m still curious what I am doing wrong here or if I misunderstand the possibilities of using if_category.
Offline
#4 2006-02-24 00:11:58
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_category won't work
Just to be clear on what if_category does, say we have three possible urls being loaded:
- http://mysite.com/
- http://mysite.com/category/pears
- http://mysite.com/category/apples
and we have the following page:
<txp:if_category>
We are viewing a category.
</txp:if_category>
<txp:if_category name="apples">
We are viewing the "apples" category.
</txp:if_category>
When we load url #1, nothing would show up. When we load url #2 we would see “We are viewing a category.” When we load url #3, we would see both “We are viewing a category.” and ‘We are viewing the “apples” category.’
Is that the kind of thing you’re after? Or are you wanting if you’re viewing a article, you see the subnav for that article’s category?
Offline
Re: if_category won't work
> mary wrote:
Or are you wanting if you’re viewing a article, you see the subnav for that article’s category?
Mary, I’d actually be interested in seeing how you would structure that kind of output. Would you use <code><txp:if_article_category></code> tags?
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#6 2006-02-24 05:42:29
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_category won't work
Yes. Obviously, it’d need to be in two different forms, since navigation is usually a little separate from article content, but it is possible (if_individual_article, if_article_category).
Offline
#7 2006-03-10 05:46:50
- jessejericho
- Member
- Registered: 2005-10-29
- Posts: 25
Re: if_category won't work
I also cannot seem to get if_category to work with my categorized articles… any suggestions?
Offline
#8 2006-03-11 02:13:52
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: if_category won't work
J: Please read the FAQ before posting.
Alex
Offline
Pages: 1