Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-27 16:47:35

vickilh
Member
Registered: 2007-10-30
Posts: 96

"if_category" showing cond. code for whole section

Hello!

I’m trying to use “if_category” on a ‘page’/section to output a bunch of html for that only category. And it works for that category — but unfortunately it keeps on displaying that html regardless of which category you’re in.

Here’s what my code is like:
—————————————————————————-

<txp:if_category name=“Email Request”> … bunch of html …..

<txp:else /> <txp:article form=“org_article” limit=“1” />

</txp:if_category>
—————————————————————————-
It seems odd that “if_category” executes the code regardless of category. [I’m probably not understanding something here? I’m still fairly new to textpattern.]

How can I display the “… bunch of html” ONLY when I’m in the “Email Request” category?

Thank you! Vicki

Offline

#2 2007-12-27 16:52:19

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: "if_category" showing cond. code for whole section

First, are you absolutely sure that Email Request is your category’s name? As the name couldn’t/shouldn’t have a space. So, you’re probably using the title instead of the name that should be used.

Cheers!

Offline

#3 2007-12-27 16:53:31

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: "if_category" showing cond. code for whole section

make sure you’re using the category NAME and not title. the title is the human-readable version while the name is the one with dashes and such.

Offline

#4 2007-12-27 17:00:22

vickilh
Member
Registered: 2007-10-30
Posts: 96

Re: "if_category" showing cond. code for whole section

Sorry, I typed in a different category name than the one I’m using. It’s actually “00-Email-Notification”. And since it’s displaying the code (all the time!), it appears to find it ok, right?

Thanks! Vicki

Offline

#5 2007-12-27 17:08:34

vickilh
Member
Registered: 2007-10-30
Posts: 96

Re: "if_category" showing cond. code for whole section

p.s.
I don’t know if it makes any difference, but I’m also using the stw_category_tree plugin. Here’s code right before the category stuff above:
—————————————————————————— <div id=“submenu”>

<!— TXP Section Name —> <h3><span><txp:s /></span></h3>

<!— TXP List of articles in this section —> <txp:stw_category_tree title=“1” prune=“false” start=”*s” onclass=“menuSelected” />

</div>
————————————————————————————
Thanks again! Vicki

Offline

#6 2007-12-27 18:30:52

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: "if_category" showing cond. code for whole section

Try if changing your category names to all lowercase helps. Uppercase in section and category names sometimes causes trouble.

Offline

#7 2007-12-27 21:03:06

vickilh
Member
Registered: 2007-10-30
Posts: 96

Re: "if_category" showing cond. code for whole section

Doesn’t work. The conditional if_category html is still showing up all the time.
—————————————————————————————-
<txp:if_category name=“00-email-notification”> …. bunch of html code ….

<txp:else /> <txp:article form=“org_article” limit=“1” />

</div>

<div id=“sidebar”> <?php include(‘../_sidebar.inc’); ?> </div>

<div id=“footer”> <?php include(‘../footer.inc’); ?> </div> </txp:if_category>
——————————————————————————
I also tried it with if_article_category, then the code is ignored. I.e., the conditional if_category html isn’t showing up all the time — but it also isn’t showing up for the category.

Thanks! Vicki

Offline

#8 2007-12-27 22:54:44

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

Re: "if_category" showing cond. code for whole section

Offline

#9 2007-12-27 23:36:05

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: "if_category" showing cond. code for whole section

vickilh wrote:

<txp:if_category name="00-email-notification”>

I don’t know if you have exactly this code on your page, but have a look at the quotes.

Offline

#10 2007-12-28 04:33:35

vickilh
Member
Registered: 2007-10-30
Posts: 96

Re: "if_category" showing cond. code for whole section

I gave up on doing it this way and crammed it into an article. Problem solved! … except for one little thing that I’ll put in a new posting.

Thanks everyone!! Vicki

Offline

#11 2007-12-28 15:33:46

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

Re: "if_category" showing cond. code for whole section

Well I’m a little late then but apart from what has already been mentioned consider the following too:-

In your submenu code you are using <txp:s /> which isn’t a proper tag. Use <txp:section title="1" /> instead or drop the “title” attribute if you really want to show the section “name”.

You are using raw PHP in your code. You would be better to use the TXP tags <txp:php></txp:php>, but this wouldn’t be necessary if you brought your sidebar and footer code into TXP as forms then you could simply use <txp:output_form form="sidebar" />.


Stuart

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

Offline

Board footer

Powered by FluxBB