Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
<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
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!
Offline
Re: <txp:if_variable> returning true when it shouldn't?
Ah, thanks. That took care of it.
Offline