Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#289 2010-02-19 09:39:01

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

Re: smd_if: Generic multiple if condition tests

roelof

Keep an eye on the details. Did you also add the missing close quote on the smd_if’s field attribute? That might help :-)

Last edited by Bloke (2010-02-19 09:40:29)


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

#290 2010-02-19 13:09:59

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Oke,

That part work now.
But one problem left.
Why the script takes the <a href> after the else and not the <a href> after the smd-if for last page.

Roelof

Offline

#291 2010-02-19 13:32:33

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

Re: smd_if: Generic multiple if condition tests

roelof wrote:

Why the script takes the <a href> after the else and not the <a href> after the smd-if for last page.

Perhaps because your 3rd smd_if is also self-closing: smd_if can only be used as a container tag. I think your closing / on that line should be for the txp:variable tag, and hence inside the tag inside the apostrophes.

Last edited by Bloke (2010-02-19 13:34:22)


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

#292 2010-02-19 13:45:09

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Hello Bloke,

I think that’s how it supposed to be.
The first smd_if is the container for the other two.
So if the total pages are bigger then 11 then I check if the pagenumber is smaller then the firstpage so that’s numbers are not displayed. Then i check if the pagenumber is bigger then the lastpage so that numbers are not displayed. Then I make the url for the pages.
else so there are lesser pages then 11 then the normal url can be maded.

Roelof

Offline

#293 2010-02-19 13:49:39

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

Re: smd_if: Generic multiple if condition tests

roelof wrote:

I think that’s how it supposed to be.

This line:

<txp:smd_if field="my_custom_field_pagenr" operator="ge" value='<txp:variable name="lastpage">'/>

Is syntactically incorrect. The closing / is currently part of the smd_if tag. It should be the closing slash of the txp:variable tag because that currently does not have one. Thus the parser will get confused.

Just move the slash back a couple of characters and it should help.


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

#294 2010-02-19 15:58:52

mlarino
Member
Registered: 2007-06-29
Posts: 367

Re: smd_if: Generic multiple if condition tests

Cant get this to work:

<txp:variable name="numresults">
<txp:smd_query query="SELECT count(*) as cantidad FROM textpattern  WHERE Section LIKE '%?opcion%' AND custom_1 LIKE '%?tipo%' " >{cantidad}</txp:smd_query>
</txp:variable>

<txp:smd_if field="txpvar:numresults" operator="gt" value="0" >
<txp:variable name="<txp:variable name="numresults" />" /> houses in NY, <a href="/results-page">see all <txp:variable name="numresultados" /></a>

<txp:else />

We are sorry, there was no results.

</txp:smd_if>

Offline

#295 2010-02-19 16:10:28

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

Re: smd_if: Generic multiple if condition tests

mlarino

Couple of things to try:

  1. Remove the line breaks around your <txp:variable> container so that the smd_query is assigned to the variable without any rogue newlines or <br /> tags in it
  2. Fix the variable definition to take account of the nested attributes, e.g.
<txp:variable name='<txp:variable name="numresults" />' /> houses in NY, <a href="/results-page">see all <txp:variable name="numresultados" /></a>

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

#296 2010-02-19 17:52:27

mlarino
Member
Registered: 2007-06-29
Posts: 367

Re: smd_if: Generic multiple if condition tests

Thanks Stef!
it was the line break problem.
Great plugin!!! helping a lot on this realestate website I am making!

Offline

#297 2010-03-02 08:43:27

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

Re: smd_if: Generic multiple if condition tests

speeke wrote:

create a new operator called bn (to stand for “between”) where the numerical values to compare could be separated by “|”?

A noble request. Leave it with me and I’ll see if the plugin can be beaten into this shape for you.


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

#298 2010-03-02 09:50:18

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

Re: smd_if: Generic multiple if condition tests

Done :-)

Two new operators for your comfort and enjoyment:

  • between for testing if the given values lie (exclusively) between the values you give
  • range is exactly the same but includes the end points as valid values

In other words, between uses > and <, whereas range uses >= and <= (the :NUM is optional for most cases). Note that you use the list_delim attribute between values, e.g. value="0/32".

See example 10 in the help for an embodiment of your post above. As always, let me know how y’all get on with this version.


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

#299 2010-03-02 11:46:53

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

Re: smd_if: Generic multiple if condition tests

speeke wrote:

except the global variable $thisyear

Bugger, more thought required. All our lines are currently busy but your call is important to us. Please hold and an operator will be with you shortly…


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

#300 2010-03-02 23:14:09

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

Re: smd_if: Generic multiple if condition tests

Sheesh, that was harder than I expected. After much fiddling and large-scale internal code refactorisation, smd_if is back with a brand new pig bag

From your perspective, there’s nothing new in this version except that you now have the capability to specify more than one field inside values. For example:

<txp:smd_if field="urlvar:tester" operator="in" value="1/3/7/?custom1/13/txpvar:some_val/19">
   // tester matches one of the values
</txp:smd_if>

In previous versions that would fail, but the plugin now correctly inserts each value — or sub-list of values! — in place of its variable and then the whole list is compared with the field. This works using operators in, notin, between and range. You’ll also get a whole load more replacement tags with these operators — one for each value in your list. That gives you more flexibility about what to display inside your container.

Because of the big changes inside the plugin I’ve bumped the major version number. This version should however be backwards compatible with previous versions; please let me know if I’ve missed anything or broken any previous smd_if magic.

Above all, enjoy.

Last edited by Bloke (2010-03-02 23:17:29)


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