Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

Re: txp if tag

Maybe this?

Offline

#3 2008-08-05 18:53:31

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

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

Board footer

Powered by FluxBB