Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2008-08-05 18:20:50
- ahlt
- New Member
- Registered: 2008-06-19
- Posts: 5
txp if tag
Hi
I was wondering if there is possible to produce if controls as Textpattern tags. I was thinking something like:
<txp:abc_if_loggedin>Hi there!</txp:abc_if_loggedin>
Is this possible, and if so, how?
Offline
#2 2008-08-05 18:40:34
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Offline
Re: txp if tag
If you’re looking to create a conditional tag, you could use something like this:
//<txp:abc_if_stuff foo="2">bar<txp:else/>baz</txp:abc_if_stuff>
function abc_if_stuff($atts, $thing)
{
extract(lAtts(array(
'foo' => '',
), $atts));
$condition = ($foo > 0);
$out = EvalElse($thing, $condition);
return parse($out);
}
Offline
#4 2008-08-05 19:01:46
- ahlt
- New Member
- Registered: 2008-06-19
- Posts: 5
Re: txp if tag
Thanks, just what I was looking for: )
Offline
Pages: 1