Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#391 2012-12-21 16:29:19
Re: smd_if: Generic multiple if condition tests
Can I check for article status?
Offline
#392 2012-12-21 16:35:54
Re: smd_if: Generic multiple if condition tests
wornout wrote:
Can I check for article status?
As in Live, Sticky, etc? Or as in HTTP status (200, 403, 404, …)?
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
#393 2012-12-21 16:37:26
Re: smd_if: Generic multiple if condition tests
As in live, sticky….
Offline
#394 2012-12-21 16:42:32
Re: smd_if: Generic multiple if condition tests
wornout wrote:
As in live, sticky….
Yes, for example:
<txp:smd_if field="article:status" operator="in" value="4/5">
LIVE OR STICKY
<txp:else />
HIDDEN, PENDING OR DRAFT
</txp:smd_if>
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
#395 2013-01-16 17:28:59
Re: smd_if: Generic multiple if condition tests
How can I check the current section?
<txp:smd_if field="s" value="usate,nuove" operator="or">
This work only for the first value…
Last edited by wornout (2013-01-16 17:29:40)
Offline
#396 2013-01-16 17:56:51
Re: smd_if: Generic multiple if condition tests
wornout
Try logic="or" instead.
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
#397 2013-01-21 04:17:00
- gfdesign
- Member

- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: smd_if: Generic multiple if condition tests
Sorry, likely I’m asking for something dumb but I can’t realize how to use this plugin for testing if body or excert fields are empty.
I’m using next codes:
<txp:smd_if field="body" operator="eg" value="">
<p>empty body</p>
<txp:else />
<div class="body">
<txp:article_custom form="body" pgonly="0" limit="1" sort="Posted asc" status="5" />
</div><!-- fin "body" -->
</txp:smd_if>
or
<txp:smd_if field="excerpt" operator="isempty" >
<p>empty excerpt</p>
<txp:else />
<div class="excerpt">
<txp:article_custom form="excerpt" pgonly="0" limit="1" sort="Posted asc" status="5" />
</div><!-- fin "excerpt" -->
</txp:smd_if>
However I don’t achieve they work. Would someone give a hand?
Many thanks and my appologies for my ignorance
Regards
Offline
#398 2013-01-21 08:05:54
Re: smd_if: Generic multiple if condition tests
gfdesign wrote:
if body or excert fields are empty.
Hmmm it works on my version 0.91 but I’m running it on a development site which uses a new version of Textile that has fixed a long-standing issue of rendering a tab character before content. So the problem might be the version of Textile that ships with Txp.
If you can look into your database via phpMyAdmin at an “empty” article, check the Body and Excerpt fields. You might find a rogue tab character or (maybe) a pair of empty <p> tags. If so that’ll be why it’s not working so you’ll need to adjust your test for that character sequence instead of using value="".
For the record, both these constructs work with the new version of Textile installed:
<txp:smd_if field="excerpt" operator="isempty">
<p>empty excerpt</p>
</txp:smd_if>
and
<txp:smd_if field="body" operator="eq" value="">
<p>empty body</p>
</txp:smd_if>
(note operator is eq not eg).
You could try updating your version of Textile (and re-saving the empty article to test) but I’m not sure if it’s compatible with earlier installations any more. Might be worth a try, though. Make sure you get the 2.5 branch because development has recently split into two parallel branches. Backup the original file first of course.
Hope that helps.
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
#399 2013-01-21 12:16:30
- gfdesign
- Member

- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: smd_if: Generic multiple if condition tests
Hi Stef.
I’ve reviewed in the database of this site in an empty article and the fields seem to be empty as well (no there is any character). It is worth mentioning that in this website, does not use Textile, it uses an editor WYSWYG “hak_tinymce” plugin instead, but only in the body field. I had been using “chh_if_data” plugin for checking if body and excerpt fields are empty, but it fails when they have a few saved characters. In any case, could you be so kind as to explain how update textile version on my site?
Many thanks for your quick reply.
Regards
Offline
#400 2013-01-21 12:26:15
Re: smd_if: Generic multiple if condition tests
gfdesign wrote:
does not use Textile, it uses an editor WYSWYG
Hmm, that is weird. smd_if should detect the fact they’re empty then, as long as hak_tinymce doesn’t add anything to the fields on save. If there are no characters in the fields as shown in phpMyAdmin — even spaces or tabs — then I find it a bit strange.
explain how update textile version on my site?
Should be as simple as:
- Backup your existing
lib/classTextile.phpfile. - Download the 2.5 version of
classTextile.phpand stick it in yourlibfolder. - Visit your article on the admin side and save it again so it gets run through Textile.
- Test smd_if with the new article.
But if you’re not using Textile then I may be wrong about it being the source of the error. Perhaps smd_if isn’t doing its job properly. You’re using 0.91, yes? I might need to put my debugging legs on.
Last edited by Bloke (2013-01-21 12:27:16)
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
#401 2013-01-21 14:46:32
- gfdesign
- Member

- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: smd_if: Generic multiple if condition tests
Ok, I’ve followed the steps but it did not work. When I did it, and then I try to access to any article then loads this page https://github.com/netcarver/textile/tree/2.5 on my Txp site :| .Other thing caught my attention was that my classTextile.php file is 51Kb (2.2v) and the new one (2.5v) is 666Kb. Can there be so much difference each other? (Must be as you have mentioned about parallel branches)
For now, it is not so important because I’m working on a test site in a free hosting account, but I just wanted comment it. Surely, many PHP functions are disabled and it doesn’t work as expected. I’ll have to try on in a paid hosting account.
BTW, yes, I’m using smd_if 0.91 on Txp 4.4.1 (PHP version 5.2.*)
Many thanks for your time.
Last edited by gfdesign (2013-01-21 14:55:54)
Offline
#402 2013-01-21 14:55:16
Re: smd_if: Generic multiple if condition tests
gfdesign wrote:
the new one (2.5v) is 666Kb. Can there be so much difference each other?
Nope. The new one should be about 91KB. See the raw file directly and do a Save Page As from your browser to obtain a copy that you can drop into your Textpattern installation.
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
#403 2013-01-21 15:17:30
- gfdesign
- Member

- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: smd_if: Generic multiple if condition tests
Sorry, You’re right. It’s 91Kb. My bad :S In any case, it didn’t work neither. I went to check back on the database, but fields are still empty (even saving the articles again). If I have best luck, I’ll let you know.
Best regards
Offline
#404 2013-07-21 01:32:51
Re: smd_if: Generic multiple if condition tests
Recent upgrade to textpattern and smd_if broke part of my site?
I have a page with a URL of the form /section/category/ which previously worked, and it works for pages I only use textpattern tags.
However, on one page I’m using smd_if and debugging shows the following:
<txp:smd_if field="category" operator="eq" value="our_story">
[<txp:smd_if field="category" operator="eq" value="our_story">: false]
</txp:smd_if>
The category not matching is odd as earlier in the same debug log I see:
<txp:page_title />
[SQL (6.29425048828E-5): select title from txp_category where name='our_story' and type='']
Which suggests to me that textpattern is recognizing ‘our_story’ as the category.
Thoughts?
Offline
#405 2013-07-21 08:40:26
Re: smd_if: Generic multiple if condition tests
mericson wrote:
<txp:smd_if field=“category” operator=“eq” value=“our_story”>
My guess is that it’s because category (somewhat bizarrely, but I had my reasons) isn’t an officially supported field. The correct way to check for ‘global’ (URL) category is by using field="c".
In versions up to 0.91 this was somewhat loosely enforced so ‘category’ was tolerated, and probably worked in most situations (although failed in others) because of a subtle oversight in my code. I closed the loophole in v0.91 when I enhanced the field attribute to work with explicit arrays.
Sorry for any hassle it’s caused. Give it a go with ‘c’ instead of ‘category’ and see if it works any better.
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