Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#61 2008-05-16 16:30:39

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: smd_if: Generic multiple if condition tests

It works like a charm. Thank you very much! Cookies :D


<txp:Ruhh />

Offline

#62 2008-05-17 15:07:24

M_i
Member
Registered: 2006-03-05
Posts: 122

Re: smd_if: Generic multiple if condition tests

How exactly do I use this for custom fields?

When I do this, nothing happens (ie, I always get ‘another’):

<txp:smd_if field="Mycustomfield"
     operator="contains"
     value="whatever">

one thing

 <txp:else />

another

</txp:smd_if>

However, when I change the field to a standards Textpattern field – say txp:smd_if field="title" – it works like a charm.

The error message I get in debugging mode is tag_error <txp:smd_if field="Mycustomfield" operator="contains" value="whatever"> -> Notice: Undefined index: Mycustomfield on line 1

The problem seems to be related to the capital in Mycustomfield. I tried using mycustomfield in the smd_if tag instead, but that won’t work, nor does changing the case sensitivity. The only way I could get it to work is by renaming the customfield to mycustomfield (ie, all lowercase), but my site relies heavily on custom fields, so renaming them would mean changing all my forms.

Is there a way of using this plugin without renaming my custom fields?

Offline

#63 2008-05-17 15:28:32

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

Re: smd_if: Generic multiple if condition tests

M_i wrote:

The problem seems to be related to the capital in Mycustomfield.

Hmmm, I don’t get an error message in debugging mode when running your example. Are you using an older version of TXP? The way stuff was stored changed around v4.0.4 (or 4.0.5) so that everything was stored as lower case (even though it appears in the admin side with the case you specified). The plugin assumes this and just lower-cases all internal variables. That could account for the behaviour you’re seeing.

Assuming you’re using v0.51 of smd_if, you could try changing the plugin code at around line 111 (just over halfway down). Find:

$fld = '$thisarticle["'.strtolower($fldParts[0]).'"]';

and replace it with:

$fld = '$thisarticle["'.$fldParts[0].'"]';

See if 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

#64 2008-05-17 16:06:25

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: smd_if: Generic multiple if condition tests

Hi Stef,
I just recently forgot that I have a very small article containing a thanks message and I would like to get rid of it but inserting a thanks message in the same article with the PHP include to the ask and answer script that is if succeeding with the else tag and/or the smd_if tags. How would I do it?

Here is the full content in the same article you helped me before:

notextile. <txp:smd_if field="urlvar:page" operator="isused">
  <txp:an7_filter>
    <txp:php>
      include('http://domain.com/ask/index.php?page=' .$_GET['page']. '&x=');
    </txp:php>
  </txp:an7_filter>
<txp:else />
  <txp:an7_filter>
    <txp:php>
      include('http://domain.com/ask/index.php');
    </txp:php>
  </txp:an7_filter>
</txp:smd_if>

I would like the url for the thanks message to be /about/ask-me/thanks.

Ohh. I just forgot that the script already have a redirect to the thanks message. So perhaps for the better, an url like index.php?a=1 with an include to that file in the same article? By the way, the thanks message should be showing up above the answered questions. That is how the script done it.

Last edited by Ruhh (2008-05-17 16:14:13)


<txp:Ruhh />

Offline

#65 2008-05-17 16:26:34

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

Re: smd_if: Generic multiple if condition tests

Ruhh wrote:

I would like to get rid of it but inserting a thanks message in the same article with the PHP include to the ask and answer script that is if succeeding with the else tag and/or the smd_if tags.

Sorry, you lost me there :-s

So you have an ordinary article with a thanks message in it, right?
And one of those PHP includes calls it? (if so, which one? The one in the ‘if’ or the one in the ‘else’?)
How does the user interact with this page? Is there a form with a submit button somewhere that they use to send an answer, and then the script is supposed to thank them?

I’m not quite sure how this application flows information between user and script and what the includes do. If I knew that I might be able to help a little more. Do you have a link to the site you could email me?

Sorry if I’m being dense. It’s the weekend :-)


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

#66 2008-05-17 16:33:30

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: smd_if: Generic multiple if condition tests

Yes, just a sticky article within the same section.

Ok, here is the source from the script that does it:

// Redirect.
	header('Location: http://domain.com/about/ask-thanks');

As you can see, I had it redirect to the article containing the thanks message. My goal is to get rid of the article and redirect to the new url page using the smd_if tags consisting the original redirect which is:

// Redirect.
	header('Location: http://domain.com/ask/index.php?a=1');

So, some more smd_if tags with an include to the file above and having the url like what you did with my multiple pages but the ending like above.

Last edited by Ruhh (2008-05-17 16:34:01)


<txp:Ruhh />

Offline

#67 2008-05-20 12:44:32

M_i
Member
Registered: 2006-03-05
Posts: 122

Re: smd_if: Generic multiple if condition tests

Bloke wrote:

Are you using an older version of TXP? The way stuff was stored changed around v4.0.4 (or 4.0.5) so that everything was stored as lower case (even though it appears in the admin side with the case you specified).

Yup. Still running 4.0.4 — made a lot of changes to it, and haven’t yet had time (or sufficient reason…) to do the same for the latest version.

Bloke wrote:

Assuming you’re using v0.51 of smd_if, you could try changing the plugin code at around line 111 (just over halfway down).

Works like a charm! Thanks!

Offline

#68 2008-05-22 12:18:01

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

Re: smd_if: Generic multiple if condition tests

Stef, would you mind implementing something like
<txp:smd_if query="query_goes_here" field="query" operator="lte" value="n">

You’d have a true swiss knife!


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#69 2008-05-22 12:25:06

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

Re: smd_if: Generic multiple if condition tests

uli wrote:

Stef, would you mind implementing something like
<txp:smd_if query="query_goes_here" field="query" operator="lte" value="n">

Are you a mind reader? :-p

Your wish will (sort of) be answered in about half an hour once I’ve written the help file. I threw together smd_query this morning which allows generic SQL queries to be executed directly from the database and the results iterated over. It’s not quite ‘if’ but it’s mental what you can do with it. Watch the forum…

And if it doesn’t fit your needs I will see what I can do about your request.


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

#70 2008-05-22 12:40:16

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

Re: smd_if: Generic multiple if condition tests

No, not a mind reader, but it had fit the character of such a mostflexible_mostversatile_multipurpose_pluginist you are ;)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#71 2008-05-22 12:43:17

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

Re: smd_if: Generic multiple if condition tests

BTW, did I mention “Awful!!” “I’m looking forward!” “Refreshing the forum list thrice a minute!” etc?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#72 2008-05-22 12:48:06

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

Re: smd_if: Generic multiple if condition tests


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