Textpattern CMS support forum

You are not logged in. Register | Login | Help

#451 2017-03-06 09:29:59

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: smd_if: Generic multiple if condition tests

Bloke wrote #304427:

Doesn’t if_excerpt do the job for you?

Documentation didn’t indicate that it will parse txp:else — I need it for “if_no_excerpt”. If it will parse txp:else then it will yes do the job :)


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#452 2017-03-06 09:47:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,674
Website

Re: smd_if: Generic multiple if condition tests

alicson wrote #304434:

Documentation didn’t indicate that it will parse txp:else — I need it for “if_no_excerpt”. If it will parse txp:else then it will yes do the job :)

All conditional tags support <txp:else />.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#453 2017-03-06 09:54:30

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: smd_if: Generic multiple if condition tests

Yay then if_excerpt is perfect :) (Documentation seems pretty consistent about individually mentioning availability of txp:else for most conditional tags.)

Am I using smd_if correctly here or can I manage this one with built-in tags too? <txp:smd_if field="category1, category2" value="ridiculi">


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#454 2017-03-06 15:04:39

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,184
Website

Re: smd_if: Generic multiple if condition tests

alicson wrote #304443:

Am I using smd_if correctly here or can I manage this one with built-in tags too? <txp:smd_if field="category1, category2" value="">

In an article list page:

<txp:if_category name="ridiculi">
        ...
</txp:if_category>

In an article form:

<txp:if_article_category name="ridiculi">
        ...
</txp:if_article_category>

Offline

#455 2017-03-08 05:38:08

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: smd_if: Generic multiple if condition tests

michaelkpate wrote #304455

Thank you!


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#456 2017-03-16 22:35:39

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: smd_if: Generic multiple if condition tests

To replace the very handy <txp:glx_if_section_frontpage>, how may I form the <txp:smd_if> ?

If needs to be specific to a particular section/page, I was thinking I could do e.g. IF <txp:page_url /> = <txp:site_url />/pictures ..
I haven’t quite wrapped my head around urlvar, etc../which fields to use in this case to effectively form the smd_if.


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#457 2017-03-16 22:45:22

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,207

Re: smd_if: Generic multiple if condition tests

Alicson, here’s a plugin-less solution. Plus several other approaches discussed in a specific topic.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#458 2017-03-17 01:26:16

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,781
Website

Re: smd_if: Generic multiple if condition tests

I gather you’re trying to cut back on plugins, but while uli is of course right that you can do section front-page checks with built-in tags, it does tend to require a rather big stack of them, so here’s another option to consider (with apologies for promoting my own plugin in a different plugin support thread!):

soo_if_frontpage


Code is topiary

Offline

#459 2017-03-18 04:00:12

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: smd_if: Generic multiple if condition tests

Thank you very much to both of you! I am cutting down on plugins, however have also been trying to cut down on extensive nested conditionals—of which I have (too) many. @uli, I really appreciate being pointed to resources; I’ve only just discovered txp:variable and I don’t think I fully understand its attributes yet; I am digesting and learning. And @jsoo your plugin offer is greatly appreciated, and will probably be the right answer for me; very practical functionality to have.


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#460 2018-04-19 13:42:26

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 640
Website

Re: smd_if: Generic multiple if condition tests

I use

<txp:variable name="social" value='<txp:custom_field name="social media" />' />	
<txp:smd_if field="txpvar:social" operator="contains" value="instagram.com"> 
	<span>instagram</span> 
</txp:smd_if>
<txp:smd_if field="txpvar:social" operator="contains" value="twitter.com"> 
	<span>twitter</span> 
</txp:smd_if>
<txp:smd_if field="txpvar:social" operator="contains" value="facebook.com"> 
	<span>facebook</span> 
<txp:else />
	<span>Other Social Media</span> 
</txp:smd_if>

Problem is, that if any but the last smd_if clauses return true, the last one still returns the code after the txp:else. How can i return this code only, when none of the above options returned true?

Last edited by jayrope (2018-04-19 13:43:50)


a hole turned upside down is a dome, though only when there’s gravity.

Offline

Board footer

Powered by FluxBB