Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-10-07 02:13:44

ashground
Member
From: Vancouver, Canada
Registered: 2005-01-07
Posts: 63
Website

<txp:if_variable> returning true when it shouldn't?

I have a page with two forms. The first form displays the current article and saves the page ID to a variable. The second form displays a list of articles, excluding the current article from the list.

The variable is saved in the article form like so:

<txp:variable name="thisid" value="<txp:article_id />" />

Then, in the article list, I check it like this:

<txp:if_variable name="thisid" value="<txp:article_id />">
	Yes: <txp:variable name="thisid" /> = <txp:article_id />
<txp:else />
	No: <txp:variable name="thisid" /> != <txp:article_id />
</txp:if_variable><br/>

There are two articles in this section, so only one should show up — the one I’m not currently viewing, right? Well, this is the output I’m getting:

Yes: 3 = 3
Yes: 3 = 2

… which, of course, makes no sense at all. How could 3 possibly equal 2? Am I missing something obvious, or did I stumble upon a bug in if_variable?

Offline

#2 2009-10-07 03:19:03

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: <txp:if_variable> returning true when it shouldn't?

Hi!
When nesting TXP tags inside TXP tags, you have to use quotes properly:

<txp:variable name="thisid" value='<txp:article_id />' />

<txp:if_variable name="thisid" value='<txp:article_id />'>
	Yes: <txp:variable name="thisid" /> = <txp:article_id />
<txp:else />
	No: <txp:variable name="thisid" /> != <txp:article_id />
</txp:if_variable>

Have fun!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2009-10-07 05:52:00

ashground
Member
From: Vancouver, Canada
Registered: 2005-01-07
Posts: 63
Website

Re: <txp:if_variable> returning true when it shouldn't?

Ah, thanks. That took care of it.

Offline

Board footer

Powered by FluxBB