Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#76 2008-05-25 09:48:36

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: smd_if: Generic multiple if condition tests

Thanks Bloke, you rule!

Offline

#77 2008-05-26 10:02:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: smd_if: Generic multiple if condition tests

Bah! Fixed a stupid oversight when generating the field names. Now, if you specify a field that doesn’t exist on the page it uses the value exactly as you specified instead of trying to find the bogus entry in $thisarticle.

That opens up even more devious tests so you can now do stuff like this inside smd_gallery:

<txp:smd_if field="{counter}" operator="gt" value="5">
  // Only display thumbs from the 6th one onwards
</txp:smd_if>

Very useful for singling out individual thumbs or only doing stuff on the 1st thumbnail, etc. Many thanks to Joana Carvalho for leading me to this fix as I tried to help her bend smd_gallery into rendering a stylish portfolio site.

V0.61 [ zipped ]


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#78 2008-06-12 00:51:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: smd_if: Generic multiple if condition tests

Another maintenance release that fixes the occasional false positive if the plugin generates an empty eval() string. Also added a new field type called NULL which is useful when comparing the result of replacement variables in smd_gallery, wet_for_each_image or smd_each (which is imminent I hope; in final testing now).

Try v0.62 | zipped


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#79 2008-07-05 14:05:38

sirblackheart
New Member
Registered: 2008-07-04
Posts: 7

Re: smd_if: Generic multiple if condition tests

Great plugin.

Only a little problem, “or” i’m only missing something?

<txp:smd_if field=“urlvar:p1” operator=“undefined , not” value=” , 1_asc” logic=“or”>
</txp:smd_if>

Shouldnt this tag write it’S content in the case, the urlvar isn’t set “or” the urlvar “p1” hasn’t the value “1_asc” ?
Seperated from each other this operators work, but they don’t seem to do in this way.
What am I doing wrong? Thx

edit:
sorry I found my error, i have to type the field two times… sorry

Last edited by sirblackheart (2008-07-05 14:39:22)

Offline

#80 2008-07-22 22:45:15

visualpeople
Member
From: Corvallis, Oregon - USA
Registered: 2005-11-16
Posts: 73
Website

Re: smd_if: Generic multiple if condition tests

I have a feeling I’m missing something easy here, so maybe all I need is another set of eyes…

I just upgraded to 4.0.6 and I swear this error wasn’t there before I ran the update, but I made a couple of other changes (I can’t recall exactly what I did, but it should have been unrelated) in the past few minutes and suddenly I noticed Tag error: <txp:smd_if field="urlvar:brand, urlvar:size, urlvar:price" operator="contains, contains, contains" value="?brand, ?size, ?price" logic="or"> -> Warning: strpos() [function.strpos]: Empty delimiter. on line 1

Here’s my form:

<txp:smd_if field="urlvar:brand, urlvar:size, urlvar:price" operator="contains, contains, contains" value="?brand, ?size, ?price" logic="or">
<tr>
<td><txp:asy_wondertag><txp:upm_article_image type="thumbnail" url="<txp:article_id/>" /></txp:asy_wondertag></td>
<td><txp:permlink><txp:title /></txp:permlink></td>
<td><txp:custom_field name="brand"/></td>
<td><txp:custom_field name="size"/></td>
<td><txp:custom_field name="price"/></td>
<td><txp:body /></td>
</tr>
</txp:smd_if>

I’ve gone over things several times, and everything seems to be outputting correctly, the error is just throwing me off… I just know I’m missing something dumb <excuse>we have a new baby in the house and I think his presence is eating my brain cells or at least severely inhibiting their function</excuse>

Offline

#81 2008-07-28 20:01:54

ultramega
Member
Registered: 2006-02-26
Posts: 221

Re: smd_if: Generic multiple if condition tests

Hmmm…. I was kindly advised by maniqui to use this plugin. I want to provide an option for user to “switch” which kind of article list is showed: few articles per page with article thumbs, or greater amount with just text-link.

So now I have in page:

<txp:smd_if field=“urlvar:textonly”
operator=“eq”
value=“yes”
>
<txp:article form=“text-list” limit=“100”>
<txp:else />
<txp:article form=“with-images” limit=“5”>
</txp:smd_if>

If I test this with linking to mysite.com/section/?textonly=yes

the list portion is empty. Actually it is now empty with plain “/section/” too, so what I’m doing wrong here?

Offline

#82 2008-07-28 23:45:55

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

Re: smd_if: Generic multiple if condition tests

Atleast close your <txp:article> tags, ie. <txp:article form="text-list" limit="100"> to <txp:article form="text-list" limit="100" />

Offline

#83 2008-07-29 08:05:22

ultramega
Member
Registered: 2006-02-26
Posts: 221

Re: smd_if: Generic multiple if condition tests

Thanks Gocom, but missing endings were only here because I wrote them wrong – the site is on local install on other computer. So copypaste didn’t work well :)

I found the reason was: I copied the example code block straight from the plugins help page, and there where those linebreaks and few additional spaces also. When I removed them, it started to work…

Offline

#84 2008-08-01 08:56:33

markgr
New Member
Registered: 2008-04-16
Posts: 4

Re: smd_if: Generic multiple if condition tests

Hi Bloke

I’ve been trying to use your plugin to check to display content via article id but with no joy.

Using a single page template I need to display one particular chunk of content along with a single article in the section but not the rest. would the following work:

<txp:smd_if field=“id” operator=“eq” value=“7”>

<div class=“tabber”> <div class=“tabbertab”> <h2>Multi Vendor Approach</h2> <txp:article_custom category=“tab1-section-identity-connects” excerpted=“0” form=“identity-connects-tabs-content” limit=“1” pgonly=“0” section=“identity-connects” sort=“Section desc” /> </div>

<div class=“tabbertab”> <h2>Ensuring Success</h2> <txp:article_custom category=“tab2-section-identity-connects” excerpted=“0” form=“identity-connects-tabs-content” limit=“1” pgonly=“0” section=“identity-connects” sort=“Section desc” /> </div>

<div class=“tabbertab”> <h2>Leading Technology</h2> <txp:article_custom category=“tab3-section-identity-connects” excerpted=“0” form=“identity-connects-tabs-content” limit=“1” pgonly=“0” section=“identity-connects” sort=“Section desc” />

</div>

</div>

<txp:else />

</txp:smd_if>

I’ve also tried to get this to work use the category2 option but with no luck.

Think I’m being a bit thick with this!

cheers
Mark

Offline

#85 2008-08-06 04:29:02

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: smd_if: Generic multiple if condition tests

Stef, top plugin thanks. I used it to present a different stylesheet to IE6 when in messy URL mode. I know, don’t ask!

Just for record here’s how:

<!--[if IE 6]>
	<txp:smd_if field="permlink_mode" operator="eq" value="messy">
	<link rel="stylesheet" type="text/css" href="./style/ie6win_messy.css" />
	</txp:smd_if>
<![endif]-->

Offline

#86 2008-08-09 11:10:27

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: smd_if: Generic multiple if condition tests

visualpeople

Sorry for the delay in replying. Confirmed as a bug. You get that error if you test a field for contents and the value to which you’re comparing is empty. In this case, you’ll get one of those nasty warning messages for every custom field you’ve left blank. I thought I’d addressed that in an earlier version of the plugin but perhaps I missed it; or maybe I’ve accidentally trashed that feature in a recent revision. Thanks for letting me know; I’ll have a look at the code and try to fix it as soon as I can.

markgr

Ah, yes, a small oversight in my docs. In article lists, the ‘id’ field isn’t filled by TextPattern. Try thisid instead:

<txp:smd_if field="thisid" operator="eq" value="7">
  // Your div block here
</txp:smd_if>

I’ll update the docs and add that field in as an alternative to id. Incidentally, if you’re ever stuck for the name of a field, use debug="2" and you’ll see a whole hunk of stuff listed. Look for two headers labelled “PRETEXT” and “THIS ARTICLE”: those contain every field that the plugin can currently ‘see’, thus you can use any of the names (to the left of the => marks) in the field attribute.

gomedia

Thanks for sharing, nice tip.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#87 2008-08-09 16:11:07

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: smd_if: Generic multiple if condition tests

Hey Chumpus>

Here’s a tantalizing problem looking for a solution which likely involves three of your plugins. Just don’t quite know how.

Let’s say that I’d like a way to use a mailing list as a low-rent user authentication database, and take my maintenance of user accounts down to zero admin.

So I’d need the following.

  1. to have a little login form that asks for user and password, where…
    • user=email address
    • pass=a users state or zip
  2. when user enters values they get stored in vars
  3. vars are compared to a dB query that looks at a postmaster subscriber table in the dB
  4. which triggers a conditional that either shows pretty content or gripes at the user
I was thinking of the ultimate tag-team
  1. smd_query
  2. smd_if
  3. txp’s new variable tag

Am I out of my freakin mind?

Offline

#88 2008-08-15 14:46:13

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

Re: smd_if: Generic multiple if condition tests

Is it possible to have two smd_if tags in the same article, for example:

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

The first smd_if part is wrong because that is what I’m trying to add in but the second smd_if part works. So how would I get the first part to work??


<txp:Ruhh />

Offline

#89 2008-08-15 15:04:49

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: smd_if: Generic multiple if condition tests

That should work in 4.0.7 with the new tag parser. BTW, you should filter $_GET with htmlspecialchars(gps('page')).

Offline

#90 2008-08-15 15:09:53

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

Re: smd_if: Generic multiple if condition tests

Ahh, well I have 4.0.6.

I almost got the added part to work but I get this error:

Parse error: syntax error, unexpected $end in /home/username/public_html/textpattern/publish/taghandlers.php(2811) : eval()'d code on line 3

What could go wrong? Here is what i have:

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

Last edited by Ruhh (2008-08-15 15:33:01)


<txp:Ruhh />

Offline

Board footer

Powered by FluxBB