Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-11-28 19:50:32

leaded
New Member
Registered: 2007-08-14
Posts: 3

Can't get an if statement for category to work

I’m trying to use a <txp:if_article_category> in a form but it won’t work. It’ll only work if I do it in the body of an article. My goal is to include a few URLs for every article that is in a particular category. I’m copying it every time now, and with it only working in the article body it’s ridiculous to add even more text.

I didn’t build the site but I’m not maintaining it and here’s how it’s set up: The page includes a form called incRightCol. The section name is Resources. The category I’d like this to display on are articles in the Resources section with the series category. But this displays nothing…

<txp:if_article_category name=“series” number=“1”>
<p>Hi!</p>
</txp:if_article_category>

I’ve tried removing the name=“series” and the “number=“1” and all three possibilities do not output Hi!. However, if I copy and paste that txp code into the body of an article with the series category and the right section, Hi! does in fact display.

Can anyone help me to understand why if_article_category doesn’t work in a form? I tried if_category first and it also did not work.

Thanks,
Alan

Edit: I put my site into Testing mode and didn’t see any errors, just nothing. I also looked at the source and <p>Hi!</p> is not being generated at all.

ALSO, if I add a <txp:else /><p>Hello!</p> it displays that correctly. So for whatever reason, when the if is placed in a form, it can’t read the category. :(

Last edited by leaded (2007-11-28 19:54:36)

Offline

#2 2007-11-28 20:27:15

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Can't get an if statement for category to work

Put your site into debug mode.
If the tag is used in the wrong context, you should see an error.

Offline

#3 2007-11-28 21:17:50

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

Re: Can't get an if statement for category to work

Offline

#4 2007-11-29 00:14:29

leaded
New Member
Registered: 2007-08-14
Posts: 3

Re: Can't get an if statement for category to work

Thanks for the debugging tip. I thought through everything and figured it out: the if_article_category tag only works within <txp:article> </txp:article> which makes sense.

The thing I’m stuck on now, is how to make it work in my default article form as well as my 3 override forms. I want to include a link to our podcast for each article in the category. So, to make it work, I pasted the podcast URL in all four forms (default and 3 override forms). I thought it would be easier to put the URL in one form, a misc form type, and include that in the four forms. But when I tried that it put the if_article_category outside of the </txp:article> tag.

I guess my question has now turned into: how can I make a form act as an “include” while still being in the article?

Thanks for the help so far!!

Offline

#5 2007-11-29 01:11:55

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

Re: Can't get an if statement for category to work

leaded wrote:

within <txp:article> </txp:article>

??? <txp:article /> is not a container tag.

It should just work in an article form. Can you post the exact content of the form, and the article tag you have on your page?

Offline

Board footer

Powered by FluxBB