Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#325 2010-06-22 15:14:17

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

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

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#328 2010-08-06 01:35:52

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: smd_if: Generic multiple if condition tests

Hi,

Is it possible to compare the parent attribute to several values without repeating the attribute ?

Thanks for your answers


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#330 2010-08-15 21:26:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,578
Website GitHub

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

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

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

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

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

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

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

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB