Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#325 2010-06-22 15:14:17
Re: smd_if: Generic multiple if condition tests
Hi Stef,
I use smd_if for render a part of an article (which is populated with custom fields) but it doesn’t work.
I don’t know where is the bug.
Can you help me?
This is my code:
<txp:smd_if field="variante-1, variante-2, variante-3" operator="isused" logic="or">
<div id="bottom-details">
<h4>Varianti</h4>
<div id="product-models">
<txp:if_custom_field name="variante-1">
<div class="model">
<div class="model-code">
<p>Articolo <txp:custom_field name="variante-1" /></p>
</div><!-- model-code -->
<div class="model-desc">
<txp:upm_textile>
<txp:custom_field name="descrizione-1" />
</txp:upm_textile>
</div><!-- model-desc -->
</div><!-- model -->
</txp:if_custom_field>
<txp:if_custom_field name="variante-2">
<div class="model">
<div class="model-code">
<p>Articolo <txp:custom_field name="variante-2" /></p>
</div><!-- model-code -->
<div class="model-desc">
<txp:upm_textile>
<txp:custom_field name="descrizione-2" />
</txp:upm_textile>
</div><!-- model-desc -->
</div><!-- model -->
</txp:if_custom_field>
<txp:if_custom_field name="variante-3">
<div class="model">
<div class="model-code">
<p>Articolo <txp:custom_field name="variante-3" /></p>
</div><!-- model-code -->
<div class="model-desc">
<txp:upm_textile>
<txp:custom_field name="descrizione-3" />
</txp:upm_textile>
</div><!-- model-desc -->
</div><!-- model -->
</txp:if_custom_field>
</div><!-- product-models -->
</div><!-- bottom-details -->
</txp:smd_if>
Offline
#326 2010-08-06 00:40:16
Re: smd_if: Generic multiple if condition tests
Bloker: how do I use this to simply test for the existence of multiple values as opposed to a single value. I tried using this:
<txp:smd_if field="article_image" operator="contains" value="," >
to no avail…
any suggestions
Offline
#327 2010-08-06 00:45:20
Re: smd_if: Generic multiple if condition tests
hi Dale,
try <txp:smd_if field="article_image" operator="contains" value="," param_delim=";">
.
That should work.
Offline
#328 2010-08-06 01:35:52
Re: smd_if: Generic multiple if condition tests
Ok that worked. Muchas Gracias Señor.
The problem was compounded a double escaping that I neglected…
Offline
#329 2010-08-15 14:51:35
Offline
#330 2010-08-15 21:26:19
Re: smd_if: Generic multiple if condition tests
NicolasGraph wrote:
Is it possible to compare the parent attribute to several values without repeating the attribute ?
I haven’t tried, but it should be possible. Example 6 in the plugin help shows how to short circuit the field
attribute. If you use the parent instead the same logic should apply. Or perhaps you could use the in
operator if you are only checking if the field is one of a set of values?
EDIT: Except I forgot the parent
attribute works differently to everything else. Hmmm…
Last edited by Bloke (2010-08-15 21:27:15)
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
#331 2010-09-15 17:30:30
Re: smd_if: Generic multiple if condition tests
Sob…
I’ve tried so hard to work out how to do this simple (I am sure) test, trawled many pages of threads and the docs Stef kindly provides, but to no avail.
If anyone can put me out of my misery I would be very grateful.
I have a custom field, called, exactly: Fluffy dog
this custom field is number 39 (using glz_custom_fields).
The field is of type ‘Select’ and is either null (not set) or has the value Yes
.
I have tried to write an smd_if
statement to check for Yes
and I can’t seem to work out how to represent the name of the field — I actually have more logic to build with this but until I can work out the syntax, I’m not going there ;)
This works <txp:custom_field name="Fluffy dog" />
insomuch as it outputs Yes
, but in the following attempts/tests all evaluate to nothing (no error, just no Yes
):
<txp:smd_if field="custom39" operator="eq" value="Yes">Yes</txp:smd_if>
<txp:smd_if field="custom_39" operator="eq" value="Yes">Yes</txp:smd_if>
<txp:smd_if field="custom 39" operator="eq" value="Yes">Yes</txp:smd_if>
<txp:smd_if field="fluffy_dog" operator="eq" value="Yes">Yes</txp:smd_if>
<txp:smd_if field="Fluffy Dog" operator="eq" value="Yes">Yes</txp:smd_if>
I’ve also tried using "eq:NOSPACE"
in case this was relevant, but to no avail.
ANY help, much appreciated. Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#332 2010-09-15 17:59:12
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,311
Re: smd_if: Generic multiple if condition tests
Alan, I don’t think you need a plugin for your issue.
<txp:if_custom_field name="Fluffy dog" val="Yes">
<p>Yes, doggy is Fluffy.</p>
<txp:else />
<p>Nope, shaggy dog!</p>
</txp:if_custom_field>
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#333 2010-09-15 18:07:24
Re: smd_if: Generic multiple if condition tests
Thanks Uli, you’re right! For my test case ;)
I actually have more logic to build with this but until I can work out the syntax, I’m not going there ;)
So once I get how to use custom fields with smd_if, I will be building more complex logic to work out some stuff here — only I dare not even start since I cannot get this simple test-case use to work (due to my inability to understand documentation I am sure).
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#334 2010-09-15 18:20:31
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,311
Re: smd_if: Generic multiple if condition tests
Have you tried renaming the cf to a space-less name? If you need the space for proper looks for your client, there’s bot_cf_titles (Hm, haven’t got a link lying around. If you need it, I’ll mail you a copy.)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#335 2010-09-15 18:23:58
Re: smd_if: Generic multiple if condition tests
Hi Uli, I think I have, I’ll try it again tho — I have over 40 fields and I am hoping I dont’ have to rename then all — kinda hoping there’s a simple, plugin-free solution for using smd_if with custom fields where the titles include spaces and/or mixed case.
I’ll keep testing in case I missed a combination that suddenly works.
Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#336 2010-09-15 18:39:18
Re: smd_if: Generic multiple if condition tests
Alan,
Quoted from Textbook: http://textpattern.net/wiki/index.php?title=custom_field
Custom names may include letters (uppercase or lowercase), numbers and under_scores, but no spaces or other special characters.
Offline