Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

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

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

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

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
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

Online

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

#343 2010-09-15 17:59:12

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

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

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

#345 2010-09-15 18:20:31

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

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

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

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

#348 2010-09-15 18:40:42

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

Re: smd_if: Generic multiple if condition tests

alanfluff

In theory there’s no need to rename the fields (although as maniqui says, it’s preferred to not use spaces) — try the field name in all lower case, because TXP internally converts them this way:

<txp:smd_if field="fluffy dog" operator="eq" value="Yes">Yes</txp:smd_if>

Or using a hyphen:

<txp:smd_if field="fluffy-dog" operator="eq" value="Yes">Yes</txp:smd_if>

If that doesn’t work, try some debug="1" and let me know the output — it might shed some light on things.

EDIT: Custom fields is one area that need serious love in TXP… one day.

Last edited by Bloke (2010-09-15 18:43:05)


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

Online

Board footer

Powered by FluxBB