Textpattern Forum

You are not logged in. Register | Login | Help

#1 2008-11-17 21:26:26

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

adi_gps – Extract GET & POST variables

Summary

adi_gps extracts GET/POST variables from the URL and assigns them to TXP variables.

See the help supplied with the plugin, or have a look online.

Features

  • ability to extract GET & POST variables from URL (individually or all in one go)
  • automatically recreate them as Textpattern variables (which can be accessed using the standard <txp:variable /> & <txp:if_variable> tags)
  • automatically make them global (for use in PHP)

Practical Examples

Personalise a feedback page:
On the client’s website, a feedback link points back to your own website. The link URL would look something like:

www.yourwebsite.com/feedback/?client=clientname

Then on your feedback page, in the welcome article, do something like:

Thank you for your feedback regarding the <txp:adi_gps name="client" /> website.

Control page output:
To display different content on a page when arriving via a particular link. Set up the link with a URL to the appropriate page & include a variable:

.../mysection/?option=extras

Then in the page for ‘mysection’ use:

<txp:adi_gps name="option" quiet="1" />
<txp:if_variable name="option" value="extras">
... do something extra ..
</txp:if_variable>

(Note the use of quiet="1" to suppress the output of the variable’s value.)

Version History

  • 0.2
    • multiple security & functionality improvements (thanks to Gocom)
    • ‘name’ attribute now accepts comma separated list
    • removed ‘txpvar’ attribute – TXP variables now always set
    • ‘post’ attribute deprecated & now ignored (default behaviour now retrieves POST vars)
    • removed ‘global’ attribute & functionality – not secure
    • ‘escape’ now enabled by default
    • removed ‘list’ & ‘debug’ attributes – debug info now in TXP tag trace (when Production Status = debugging)
    • new attribute ‘type’
  • 0.1
    • initial release

Requirements

Tested in:

  • Textpattern 4.0.7+ (r2989), MySQL 5.0.45, PHP 5.2.4

adi_gps can be installed in pre-4.0.7 versions of Textpattern but obviously the creation of TXP variables can’t be performed. Use attribute txpvar="0" to switch this off.

Download & Installation

Download adi_gps and install the plugin in the usual way.

Bugs & Limitations

Let me know if you find any problems.

Feedback

Comments are most welcome.

Last edited by gomedia (2012-01-30 06:20:00)

Offline

#2 2008-11-18 05:28:24

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,064
Website

Re: adi_gps – Extract GET & POST variables

hmmm, me likey.

Offline

#3 2008-11-18 09:05:50

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

Re: adi_gps – Extract GET & POST variables

Mighty fine stuff. Among myriad applications I can already envisage, this will make an excellent companion to smd_if to make it easier to test for stuff on the URL line. The rename and decode attributes are muchos useful, and integration with <txp:variable /> is an excellent move.

Hats off to ya.

Last edited by Bloke (2008-11-18 09:06:24)


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

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2008-11-18 09:20:24

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

Re: adi_gps – Extract GET & POST variables

mrdale wrote:

hmmm, me likey.

Oh, goody.

Offline

#5 2008-11-18 09:44:10

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

Re: adi_gps – Extract GET & POST variables

Bloke wrote:

Mighty fine stuff … Hats off to ya.

Thanks very much. I’ve just converted my (handcoded PHP) site to Textpattern and 95% of it could be achieved with the standard tags/plugins but accessing the URL vars was one of the things that needed a bit of polish.

The ‘decode’ bit came about because I had to employ a touch of htaccess redirect and “client%20name” was appearing out the other side as “client%2520name” – so an extra urldecode() was called for.

I reckon TXP variables are an absolute master stroke – they make Textpattern so much more programmable at the basic level. 4.0.7 is going to be a top release – tags in tags, variables, expiry dates … Christmas has come early (thanks to SVN)!

Cheers.

Offline

#6 2008-11-18 10:07:11

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

Re: adi_gps – Extract GET & POST variables

gomedia wrote:

I reckon TXP variables are an absolute master stroke – they make Textpattern so much more programmable

I agree. They make far more personable and customisable sites possible out of the box. And this plugin just made it a hell of a site easier to create them on the fly. Marvellous!

OT: I wonder when would be a good time to broach the subject with the dev team about expanding txp:variable’s scope to be able to handle the concept of array-type data. e.g. some sort of comma-separated list as a value within which you can append, remove or replace items inside the value?! Or perhaps add a dedicated <txp:varray /> ;-)

Geeks’ dream.

Last edited by Bloke (2008-11-18 10:08:24)


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

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2008-11-18 10:46:18

Gocom
Developer
Registered: 2006-07-14
Posts: 4,476
Website

Re: adi_gps – Extract GET & POST variables

Bloke wrote:

<txp:varray />

Yeay, SQL :)

Geeks’ dream.

Wet dream and amazingly hot (sounds nasty, so does varray) ;D

I agree. They make far more personable and customisable sites possible out of the box.

Yep, but I’m not so impressed; reason: I’m not going to use variable so much( – ever). It’s nice feature, me likes but well… Maybe I’m losing my dark side (a coder side) :D Varible<3Love. Variable, my lost puppy.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#8 2008-11-18 15:58:53

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,064
Website

Re: adi_gps – Extract GET & POST variables

Gocom wrote: Yep, but I’m not so impressed; reason: I’m not going to use variable so much( – ever). It’s nice feature, me likes but well… Maybe I’m losing my dark side (a coder side) :D Varible<3Love. Variable, my lost puppy.

gocom has just officially lost it.

Offline

#9 2008-11-18 18:53:26

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

Re: adi_gps – Extract GET & POST variables

Hai,

I found a little problem.

I have this page template :
bc.. <txp:if_section name=”,default”>
<txp:if_category name=“zwangerschap,jaar1,jaar2,jaar3,jaar4”>
<txp:adi_gps name=“month” quiet=“1” />
<txp:adi_gps name=“page” quiet=“1” />
<txp:if_variable name=“month” value=“2004-05”>
<txp:article limit=“1” form=“dagboek” sort=“Posted asc” />
<txp:ob1_pagination outputlastfirst =“0” outputnextprevious=“0” />
</txp:if_variable>
<txp:else />
<txp:article_custom section=“voorpagina” form=“default” />
</txp:if_category>
</txp:if_section>

But if i have this url : http://test2.tamarawobben.nl/?c=zwangerschap&month=2005-04.

I get a false.

What went wrong ?

Roelof

Offline

#10 2008-11-18 19:19:23

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,189
Website

Re: adi_gps – Extract GET & POST variables

roelof wrote:

<txp:if_variable name="month" value="2004-05">
But if i have this url : http://test2.tamarawobben.nl/?c=zwangerschap&month=2005-04.

Do you mean to have URL http://test2.tamarawobben.nl/?c=zwangerschap&month=2004-05


My Plugins

Piwik Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

Board footer

Powered by FluxBB