Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#433 2015-02-27 19:07:15

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

Re: smd_if: Generic multiple if condition tests

I’ve reduced the output of the url to a single word – Active.

Something is still preventing SMD_IF from seeing it.

I may have to switch from coffee to Scotch.

Offline

#434 2015-02-27 22:27:48

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

Re: smd_if: Generic multiple if condition tests

towndock wrote #288644:

Something is still preventing SMD_IF from seeing it.

It’s not executing the code. I think maybe we should be using ‘echo’ instead of ‘return’, but it’s possible your prefs aren’t set to permit PHP to run? You’ve got mail.


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

#435 2015-04-03 19:39:51

phuture303
Member
Registered: 2008-09-14
Posts: 127

Re: smd_if: Generic multiple if condition tests

Hi, I want to do a simple test: My custom field named oddFr1 has the value 15:00x, I’m using the glz_custom_field plugin.

<txp:smd_if field="oddFr1" operator="contains" value="x">
    yes
<txp:else />
    no
</txp:smd_if>

… but the result is “no” – and I don’t know why!

<txp:smd_if field="oddFr1" operator="contains" value="x">
   [<txp:smd_if field="oddFr1" operator="contains" value="x">: false]
</txp:smd_if>

I tried 1500x instead of 15:00x and I tried with operator ends instead of contains. There must be something wrong but I don’t find it :-)

Thanks in advance!
David

Textpattern-Version: 4.5.7 (r5900), PHP-Version: 5.6.0 (56STABLE-STANDARD)

EDIT: Okay, found the problem – the naming of the custom field! oddFr1 doesn’t work, oddfr1 does. CamelCase is not accepted, too bad.

Last edited by phuture303 (2015-04-03 20:23:30)

Offline

#436 2015-04-03 21:39:19

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: smd_if: Generic multiple if condition tests

phuture303 wrote #289716:

EDIT: Okay, found the problem – the naming of the custom field! oddFr1 doesn’t work, oddfr1 does. CamelCase is not accepted, too bad.

Textpattern turns the field names (ASCII characters anyhow) to lowercase during extraction. Most likely smd_if doesn’t and because of it won’t find the field by the name.

Offline

#437 2015-04-04 05:32:20

phuture303
Member
Registered: 2008-09-14
Posts: 127

Re: smd_if: Generic multiple if condition tests

Gocom wrote #289720:

Textpattern turns the field names (ASCII characters anyhow) to lowercase during extraction. Most likely smd_if doesn’t and because of it won’t find the field by the name.

Thanks! Took me a while to fine out :-)

Offline

#438 2015-07-06 14:41:16

mmelon
Member
Registered: 2006-03-02
Posts: 95

Re: smd_if: Generic multiple if condition tests

Hi,

I am struggling today to do something that should be easy for smd_if. I am inside a <txp:category_list> container, and I want to output different markup based on the level of the current category.

<txp:php>
global $variable;
$variable['mainCategory'] = gps('maincat');
</txp:php>

<txp:category_list parent='<txp:variable name="mainCategory"/>' children="1" type="article">
some sort of smd_if condition to trap and branch on the category level.

Thanks for any insight,
Mike

Offline

#439 2015-07-06 19:45:31

mmelon
Member
Registered: 2006-03-02
Posts: 95

Re: smd_if: Generic multiple if condition tests

Hi, I’ve found my conditions won’t work as nothing is output in $parentcats unless I am in a ?c= category context. I just want to iterate over the parent category and children, and know what level they reside at as I am outputting them. Not sure why that needs a URL category context, when the category tag accepts a name attribute.

Offline

#440 2015-07-06 22:15:21

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

Re: smd_if: Generic multiple if condition tests

mmelon wrote #292679:

Not sure why that needs a URL category context, when the category tag accepts a name attribute.

Have you tried using category instead of c? That will check against the current category inside loops. At least, it should.

But even so, I’m not sure it’ll help you as I’m not entirely convinced this is achievable without some hacking. The operator does have the :LVLn and :KIDS modifiers, which might be able to help but it may mean stashing the results in a txp:variable and testing for it. Not pretty.


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

#441 2016-01-30 10:46:04

sochicomputerRU
Member
From: Россия
Registered: 2013-01-18
Posts: 61
Website

Re: smd_if: Generic multiple if condition tests

If can’t seem to get this working. I want to test if comment_email == ‘a@b.com’, and if it is then execute a line of code.

<txp:smd_if field="<txp:comment_email />" operator="eq" value="a@b.com" case_sensitive="0">
  <h1>execute some code</h1>
</txp:smd_if>

Never mind never mind. The solution was to use ‘ instead of “ around txp comment email.

Last edited by sochicomputerRU (2016-01-30 11:10:57)

Offline

#442 2016-03-14 17:24:04

lionel865
New Member
Registered: 2016-03-14
Posts: 1

Re: smd_if: Generic multiple if condition tests

Hello,

I have a problem and i don(t know what is it .

My code is :

<txp:smd_if field=“txpvar:section” operator=“not” logic=“or” value=“brunes,blondes, ambres,noires,speciales” >

//show anything

</txp:smd_if>

thanck

Offline

#443 2016-03-14 21:21:13

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: smd_if: Generic multiple if condition tests

Not sure what you’re trying to do, but could you perhaps do it this way instead by using the else case of if_section:

<txp:if_section name="brunes,blondes,ambres,noires,speciales"><txp:else />

  <p>This section is not brunes, blondes, ambres, noires or speciales</p>

</txp:if_section>

TXP Builders – finely-crafted code, design and txp

Offline

#444 2016-03-14 22:50:29

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

Re: smd_if: Generic multiple if condition tests

lionel865

If what jakob suggests isn’t what you’re intending, you might have more luck with this syntax for smd_if:

<txp:smd_if
   field="txpvar:section"
   operator="notin"
   value="brunes/blondes/ambres/noires/speciales">
//show anything
</txp:smd_if>

Each time you were using the comma it was comparing the individual items in your list against the field but using the not operator for the first comparison only. Thereafter it used the default operator, eq. So your statement was equivalent to this:

<txp:smd_if
   field="txpvar:section"
   operator="not,eq,eq,eq,eq"
   value="brunes, blondes, ambres, noires, speciales"
   logic="or">
//show anything
</txp:smd_if>

Which failed because one of them matched exactly. What you probably meant was:

<txp:smd_if
   field="txpvar:section"
   operator="not, not, not, not, not"
   value="brunes, blondes, ambres, noires, speciales"
   logic="or">
//show anything
</txp:smd_if>

But the notin version is probably more efficient. And jakob’s is even better if it does what you want.

Hope that helps.


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

Board footer

Powered by FluxBB