Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#436 2016-04-14 21:18:12

lazlo
Member
Registered: 2004-02-24
Posts: 110

Re: smd_if: Generic multiple if condition tests

Bloke wrote #298610:

Firstly, could you go back to basics, copy the code above and see what you get out. If it works we may need to investigate how your direction variable is being populated.

Thank you very much Stef, unbeknownst to me there was a char limit exception on PHP code that populated direction. I thought I had sanitized my test before contacting you, thanks for the help in confirming that it was my problem and not a problem with smd_if.

Offline

#437 2017-03-06 03:53:21

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

Re: smd_if: Generic multiple if condition tests

Tag error: <txp:smd_if field="excerpt" operator="isempty"> ->  Textpattern Notice: unregistered_tag while parsing form None on page sandbox
textpattern/lib/txplib_publish.php:518 trigger_error()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/publish.php:1006 parse()
textpattern/publish.php:1110 doArticles()
textpattern/publish.php:1099 parseArticles()
article_custom()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()
textpattern/lib/txplib_publish.php:514 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php:4476 parse()

Testing here

Calling it as such:

<txp:smd_if field="excerpt" operator="isempty"> aaaaaa <txp:body /><txp:else /> bbbbbb
<txp:excerpt /> cccccc <txp:permlink>more</txp:permlink> 
</txp:smd_if> dddddd

Smd_if plugin seems to be working correctly on the frontend; I just want to make sure I’m doing it right/am I missing something that’s causing the error?


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

Offline

#438 2017-03-06 05:19:43

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

Re: smd_if: Generic multiple if condition tests

Okay so plugin help indicates that my usage won’t work (although it seemed to, on the frontend), however I’m not so far able to wrap my head around what the correct tag should be.. I would just like to check whether the excerpt field is empty (or not).


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

Offline

#439 2017-03-06 08:38:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,485
Website GitHub

Re: smd_if: Generic multiple if condition tests

alicson wrote #304419:

I would just like to check whether the excerpt field is empty (or not).

Doesn’t if_excerpt do the job for you? And don’t worry about any ‘unregistered tag’ warnings: they’re just warnings for now and will be for a version or two of Textpattern yet. I’ll tend to each plugin as I get a chance.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#440 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

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,485
Website GitHub

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.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#442 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

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

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

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

#444 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

#445 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

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

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

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

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

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
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

#448 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

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

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

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, when there’s also gravity.

Offline

#450 2018-04-19 13:48:44

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,389
Website GitHub Mastodon Twitter

Re: smd_if: Generic multiple if condition tests

I think that the name of the social media custom field should not contain any spaces.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB