Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 Today 18:18:08

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,249
Website Mastodon

is there a Txp if/else equivalent

Curious If Textpattern tags allow for if/else based on a url title is equal to, do this, else, not.

{if article_id_12 == ""} 
<li class="active"><a href="https://textism.ca/brands/logo_ford/"> </a></li> 
{/if} 
{if article_id_12 != ""} 
<li><a href="https://textism.ca/brands/logo_ford/"> </a></li>
{/if}

it would be cool if there was.


…. texted postive

Offline

#2 Today 19:02:44

etc
Developer
Registered: 2010-11-11
Posts: 5,650
Website GitHub

Re: is there a Txp if/else equivalent

This, maybe?

<txp:if_custom_field name="url_title" value="title_to_match">
    yep
<txp:else />
    nope
</txp:if_custom_field>

Offline

#3 Today 20:28:09

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,156
Website GitHub

Re: is there a Txp if/else equivalent

And as an extra, if it’s just to set the class="active" on the currently shown article, you can do:

<li<txp:if_article_id> class="active"</txp:if_article_id>>
    <txp:permlink><txp:title /></txp:permlink>
</li>

TXP Builders – finely-crafted code, design and txp

Online

Board footer

Powered by FluxBB