Textpattern Forum

You are not logged in. Register | Login | Help

#211 2009-02-25 16:16:40

hamato
New Member
Registered: 2009-02-21
Posts: 9

Re: smd_if: Generic multiple if condition tests

No difference. :( That trick does work, but sort='FIELD(ID,<txp:variable name="ids" />)' and sort="custom_9 asc" are giving same results (as expected when I think about it). The moment I add a sort attribute to article_customlimit and offset gets broken. Or at least, they are not working as I would want. I don’t know why exactly.

Thanks anyway for trying to help me. Much appreciated. I’m feeling bad for spamming this thread about stuff that is not that much related to smd_if…. or it is? Maybe I should start a new topic in “How Do I…? & Other Questions” section. (edit: and I did… )

Sometimes simple thing make you spend hours and hours working. :(

Last edited by hamato (2009-02-25 19:41:33)

Offline

#212 2009-03-20 17:56:56

kostas45
Member
From: Greece
Registered: 2007-11-08
Posts: 61

Re: smd_if: Generic multiple if condition tests

Hi,

This is probably a stupid question, but here it is:

How do I access $_POST[ ] variables?
I can access $_GET[ ] variables with urlvar:var_name, but what about post variables?

Thanks,
Kostas

Offline

#213 2009-03-20 19:43:15

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,909
Website

Re: smd_if: Generic multiple if condition tests

kostas45 wrote:

How do I access $_POST[ ] variables?

Not a stupid question at all because the plugin, ahem *cough* can’t access them. It’s a ridiculous oversight on my part and I can’t believe it’s taken over a year for someone to notice! Thanks for spotting it.

For the vageuly interested I started out using TXP’s built-in gps() function which grabs either POST or GET, but if neither exist it sets an empty value (the ‘s’ of gps). When trying to testi if a value has been used (at all) this is no good, so I ripped out the gps() calls and replaced them with (albeit unsafe) $_GET calls. And promptly forgot to add $_POST as well. D’oh!

I’ll have it fixed in no time. Here is some hold music…


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#214 2009-03-20 20:36:51

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,909
Website

Re: smd_if: Generic multiple if condition tests


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#215 2009-03-21 09:25:19

kostas45
Member
From: Greece
Registered: 2007-11-08
Posts: 61

Re: smd_if: Generic multiple if condition tests

Excellent, works like a charm!
Thanks a lot Stef :-)

Cheers,
Kostas

Offline

#216 2009-03-22 11:10:14

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 906
Website

Re: smd_if: Generic multiple if condition tests

Hi Stef,

Having great time with your indispensable smd_if, thanks.

Now that we’re all doing lovely tags within tags, there’s an increased danger of whitespace creeping in where you don’t expect it. This might lead to problems, for example:

<txp:variable name="x" value=" 9 " />
<txp:variable name="y" value="1" />
<txp:smd_if field="txpvar:x" operator="lt" value="txpvar:y">
<txp:variable name="x"/> is less than <txp:variable name="y"/>
</txp:smd_if>

Note the spaces around the x variable’s value. This interferes with the “less than” comparison & things go awry. Is this something that smd_if could cater for or do we just need to be very careful?

Cheers,

Adi

Offline

#217 2009-03-22 19:50:15

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,909
Website

Re: smd_if: Generic multiple if condition tests

gomedia wrote:

Now that we’re all doing lovely tags within tags, there’s an increased danger of whitespace creeping in where you don’t expect it.

Glad you’re finding the plugin useful. There’s a kind of undocumented solution to the spaces thing (err, I think). If you are expecting a value (or a field) that may have spaces in it, add :NOTAGS to the variable (e.g. txpvar:x:NOTAGS). That strips out PHP and HTML tags from the string and also performs a trim() to remove whitespace (because often simply removing tags leaves extraneous whitespace lying around).

If it helps any — and you can perhaps see a situation when you may need to trim extraneous spaces without stripping PHP/HTML tags — I could add a dedicated TRIM modifier to the next version? Currently, the NOSPACE modifier could be (mis)used if you like, but since it only works on fields you’d have to switch your value/field attributes over which may or may not yield the desired true/false result from the plugin.

Let me know if you think a TRIM modifier would help (and any other modifiers you might consider useful — I could add them all at once).

Last edited by Bloke (2009-03-22 19:50:51)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#218 2009-03-22 20:57:00

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 906
Website

Re: smd_if: Generic multiple if condition tests

Bloke wrote:

Let me know if you think a TRIM modifier would help …

Thanks Stef, I think it would be a useful safety harness. And it would mean that we could keep some semblance of readability in the source code – so instead of:

<txp:variable name="height" value='<txp:upm_article_image><txp:upm_img_full_height /></txp:upm_article_image>' />

We could do:

<txp:variable name="height" value='
  <txp:upm_article_image>
    <txp:upm_img_full_height />
  </txp:upm_article_image>
'/>

and not have to worry about blanks/tabs/newlines etc.

Cheers,

Adi

Offline

#219 2009-03-22 21:28:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,909
Website

Re: smd_if: Generic multiple if condition tests


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#220 2009-03-22 21:47:53

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 906
Website

Re: smd_if: Generic multiple if condition tests

Stef,

Blimey, you’re quick off the mark. Thanks.

Too quick for me! I’d just sat down to send you another suggestion: a trim="1" attribute, to save having to use a modifier in both field & value.

All the best,

Adi

Offline

Board footer

Powered by FluxBB