Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#376 2012-03-01 21:18:54
Re: smd_if: Generic multiple if condition tests
Thanks Stef!
Offline
#377 2012-06-05 13:14:45
Re: smd_if: Generic multiple if condition tests
Hi,
I’m having troubled using this tag with a multi-select field defined using glz_custom_fields.
The field name is called Utilizzo and the options are:
Professionale
Educazione
Tempo-libero
In an article I have opted for the first two.
If I use <txp:smd_if field="Utilizzo" operator="contains" value="Professionale" >This is a test</txp:smd_if> I don’t get anything displayed.
If I change the field type to Select, than it works.
If I just display the value of the field using <txp:custom_field name="Utilizzo"/> I get: Educazione|Professionale
Any ideas?
Offline
#378 2012-06-07 12:05:53
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,316
Re: smd_if: Generic multiple if condition tests
I’d say it might be an upper/lowercase issue. If you hadn’t written this:
If I change the field type to Select, than it works.
On the other hand: the field type is saved in the txp_prefs table. Where (I’d bet any amount) smd_if never goes looking for its evaluations.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#379 2012-06-07 12:34:24
Re: smd_if: Generic multiple if condition tests
If you hadn’t written this: If I change the field type to Select, than it works. …
Presumably it’s because you can’t choose multiple options with a normal select so there will be only one item and no | in the custom field value. In effect the operator contains is then eq.
I can’t immediately see why it’s not working either, unless the pipe (|) is being (mis)interpreted as an operator. Not sure if upper/lowercase should be an issue as smd_if is by default case-insensitive, although you can set that with the case_sensitive operator.
You might also want to try stripping out the | from the field by using smd_if’s filter attribute. I’ve not tried it but maybe:
<txp:smd_if field="Utilizzo" operator="contains" value="Professionale" filter="/[^a-zA-Z]+/" replace=" ">
This is a test
</txp:smd_if>
If I’ve not made a mistake that should replace anything that is not A-Z or a-z in the field with a space…
Last edited by jakob (2012-06-07 12:37:39)
TXP Builders – finely-crafted code, design and txp
Offline
#380 2012-06-07 13:16:09
Re: smd_if: Generic multiple if condition tests
Hi,
I changed the field name and options to all lower case and it works (without jakob’s filter).
Not sure why.. but I’m happy :)
Thanks for your help!
Offline
#381 2012-07-26 15:29:43
Re: smd_if: Generic multiple if condition tests
For the record (and maybe for the help documents too).
idis always the id of current page’s article (i.e. the id of current individual article)thisidis the id of current context article. For example, in anarticle_customloop,thisidtakes the value of the article currently being iterated.
For example, if you need to simulate txp:if_article_id, using smd_if, it would be like this:
<txp:smd_if field="thisid" operator="eq" value="?id">
The advantage of this one over txp:if_article_id is that you could check for other conditions, using logic="OR".
Offline
#382 2012-09-28 20:22:49
Re: smd_if: Generic multiple if condition tests
I’m not sure if I understand how the parent value for field attribute works. I’m not even sure if I needed for what I’m trying to achieve:
Is it possible to test if current (global) category has no children? I don’t think I need to traverse up the category tree for that, but I may be missing something.
Offline
#383 2012-12-12 14:49:58
- gfdesign
- Member

- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: smd_if: Generic multiple if condition tests
Hi, a quick question.
How I should use it if I want to know if a body or excerpt article has content or not ?
I was using <txp:chh_if_data> but it does not work / comply when the output is less than 39 characters :| (unless when I’m displaying articles from a specific category)
<txp:chh_if_data>
<txp:article_custom form="body" pgonly="0" limit="1" section='<txp:section />' sort="Posted asc" status="5" category='<txp:category title="0" />' />
<txp:else/>
<p>NO THERE CONTENT IN BODY ARTICLE</p>
</txp:chh_if_data>
Thanks
Last edited by gfdesign (2012-12-12 14:56:31)
Offline
#384 2012-12-12 19:48:53
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,316
Re: smd_if: Generic multiple if condition tests
Without plugin?
<txp:variable name="checkcheck"><txp:article_custom form="body" limit="1" section='<txp:section />' sort="Posted asc" status="sticky" category='<txp:category title="0" />' /></txp:variable>
<txp:if_variable name="checkcheck" value="">
<p>NO THERE CONTENT IN BODY ARTICLE</p>
<txp:else/>
<txp:variable name="checkcheck" />
</txp:if_variable>
status 5 is sticky, right? (No further proofreading done.)
Last edited by uli (2012-12-12 21:19:33)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#385 2012-12-12 20:03:05
- GugUser
- Member

- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,477
Re: smd_if: Generic multiple if condition tests
Or:
<txp:if_custom_field name="body">
something
<txp:else />
other thing
</txp:if_custom_field>
Offline
#386 2012-12-12 21:10:52
- gfdesign
- Member

- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: smd_if: Generic multiple if condition tests
uli dijo:
Without plugin?
status 5 is sticky, right? (No further proofreading done.)
Yes, I use an sticky article just to describe different categories. About your code, it works! but I’ve modified it as follows:
<txp:variable name="checkcheck"><txp:article_custom form="body" limit="1" section='<txp:section />' sort="Posted asc" status="sticky" category='<txp:category title="0" />' /></txp:variable>
<txp:if_variable name="checkcheck" value="">
<p>NO THERE CONTENT IN BODY ARTICLE</p>
<txp:else/>
<txp:variable name="checkcheck" />
</txp:if_variable>
I thought I couldn’t store big chains text in a TXP variable :P
Many thanks
Offline
#387 2012-12-12 21:19:12
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,316
Re: smd_if: Generic multiple if condition tests
gfdesign wrote:
but I’ve modified it as follows:
Ah, the slash in the closing variable tag. Glad it didn’t make you stumble. Will correct that above.
I thought I couldn’t store big chains text in a TXP variable :P
Me neither, but I learnt it even spares one query.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#388 2012-12-12 21:20:10
- gfdesign
- Member

- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: smd_if: Generic multiple if condition tests
GugUser dijo:
Or:
bq. <txp:if_custom_field name=“body”> something
<txp:else /> other thing
</txp:if_custom_field>
In this case, I’m not using custom_field
I wondered with body or excerpt texts of an article.
Regards
Last edited by gfdesign (2012-12-12 21:24:39)
Offline
#389 2012-12-12 23:33:11
- GugUser
- Member

- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,477
Re: smd_if: Generic multiple if condition tests
The example checks the body field.
Offline
#390 2012-12-13 15:56:45
Re: smd_if: Generic multiple if condition tests
Documentation needs enhancement(s) regarding TXP core fields which can be checked via if_custom_field name="list of TXP core fields".
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline