Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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: 11,243
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.

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

#91 2008-08-15 17:46:33

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

Re: smd_if: Generic multiple if condition tests

Hmmm, if this is in an article, have you set it to ignore Textile? Putting PHP tags in a textiled article sometimes gives freaky unexpected results like that, in my experience.

EDIT: also, the dangling single quote in the last line :-)

Last edited by Bloke (2008-08-15 17:47:39)


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

#92 2008-08-15 17:53:36

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

Re: smd_if: Generic multiple if condition tests

Well I did insert notextile. I also insert another before the added part but I still get an error.

OH. I need to add in another quote, the ending to the first quote?

Now working :)

Last edited by Ruhh (2008-08-15 18:46:11)


<txp:Ruhh />

Offline

#93 2008-08-15 19:02:29

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

Re: smd_if: Generic multiple if condition tests

Err! I don’t think I’m happy with the result.

I don’t know if it has to do with the version of TXP but I put in two else tags along with two smd_if tags. Is that possible?

Here is my code:

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

the a page have no errors but the numbered page gets this error:

Notice: Undefined index:  page  on line 1

Last edited by Ruhh (2008-08-15 19:06:40)


<txp:Ruhh />

Offline

#94 2008-08-15 19:05:44

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_if: Generic multiple if condition tests

No, it isn’t possible to nest identical tags in 4.0.6. It will be possible in next version.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#95 2008-08-15 19:07:42

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

Re: smd_if: Generic multiple if condition tests

Ah.. okay. Is there a download of 4.0.7 available?

I got both parts to work by using chh_if_data tags.

Last edited by Ruhh (2008-08-15 19:13:26)


<txp:Ruhh />

Offline

#96 2008-08-16 12:05:13

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

Re: smd_if: Generic multiple if condition tests

I made some time ago an alternative article listing. User can select to list articles with or without article image thumbs. No I’m in need to offer second textlist, this time sorted and titled by data in custom field. I don’t currently have access to dev machine, but obviously this wont be work – because of one smd_if inside other?

smd_if urlvar textonly = yes
     |
    show textlist, form = article title-based listing 
txp:else
     | 
     smd_if urlvar textonly_v2 = yes
                  | 
                  show textlist, form = custom1 as link, sortby = custom1
     /smd_if
     |
txp:else
           | 
           normal list with images
/smd_if

Hmm… any ideas? Wouldn’t mind to build extra-page with article custom, if it is avoidable.

Offline

Board footer

Powered by FluxBB