Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#421 2015-02-27 17:53:44
Re: smd_if: Generic multiple if condition tests
If I hard code in “Active” – SMD_IF works fine.
Here is the debug code (in this example the variable is “gyx_status”):
TEST 1
array (
0 => 'txpvar',
1 => 'gyx_status',
)
array (
0 => 'contains',
)
array (
0 =>
array (
0 => 'Active',
),
)
@$replacements['{smd_if_gyx_status}'] = $variable["gyx_status"];
@$replacements['{smd_if_len_gyx_status}'] = strlen($variable["gyx_status"]);
$out[0] = (isset($variable["gyx_status"]) && strpos(strtolower($variable["gyx_status"]), strtolower('Active')) !== false) ? 'true' : 'false';
RESULT:
array (
0 => 'false',
)
REPLACEMENTS:
array (
'{smd_if_val1}' => 'Active',
'{smd_if_len_val1}' => 6,
'{smd_if_gyx_status}' => '<?php
return file_get_contents(\'http://wave.marineweather.net/test/test.php\');
?>',
'{smd_if_len_gyx_status}' => 86,
)
It does seem like it almost has to be hidden character(s). I’m trying to check with other tools…
Offline
#422 2015-02-27 19:07:15
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
#423 2015-02-27 22:27:48
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
Online
#424 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
#425 2015-04-03 21:39:19
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
#426 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
#427 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
#428 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
#429 2015-07-06 22:15:21
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
Online
#430 2016-01-30 10:46:04
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
#431 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
#432 2016-03-14 21:21:13
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