Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
@variable@ container tag when tag is empty
I was surprised to discover that this:
<txp:variable name="test"></txp:variable>
is not equivalent to this:
<txp:variable name="test" value="" />
It is, rather, equivalent to this:
<txp:variable name="test" />
i.e., it doesn’t actually assign anything, it just returns the variable.
Various Txp tips include this kind of construct:
<txp:variable name="has_articles"><txp:article limit="1">1</txp:article></txp:variable>
which will produce unexpected results when there are no articles. If this is an attempt to initialize the variable, it will throw a tag error. If the variable already exists, this will simply return its value. You should use single-tag mode to assign variables unless you are certain the container will never be empty. I don’t know if this is intentional behavior, but it is counter-intuitive. Changing it is trivial:
$HeadURL: https://textpattern.googlecode.com/svn/releases/4.3.0/source/textpattern/publish/taghandlers.php $
$LastChangedRevision: 3443 $
...
4501 if (!isset($atts['value']) and is_null($thing))
Code is topiary
Offline
Offline
Re: @variable@ container tag when tag is empty
This looks like an oversight.
Offline
Re: @variable@ container tag when tag is empty
Fixed in r3471. Thanks, Jeff.
Offline