Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-11-17 21:26:26
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
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 (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)
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.4
- updated for TXP 4.6 trace
- 0.3
- copes with forms which supply data as arrays (checkboxes)
- new attribute ‘glue’
- TXP 4.6 tag registration
- 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
Textpattern 4.0.7+
Download & Installation
Download adi_gps and install in the usual way.
Bugs & Limitations
Let me know if you find any problems.
Feedback
Comments are most welcome.
Last edited by gomedia (2016-06-21 22:55:49)
Offline
Re: adi_gps – Extract GET & POST variables
hmmm, me likey.
Offline
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. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#4 2008-11-18 09:20:24
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
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: 1,373
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
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. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
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.
Offline
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: 647
Re: adi_gps – Extract GET & POST variables
Hai,
I found a little problem.
I have this page template :
<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
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
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
#11 2008-11-18 19:24:37
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: adi_gps – Extract GET & POST variables
yep, that’s what i say .
Roelof
Offline
#12 2008-11-18 19:36:56
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: adi_gps – Extract GET & POST variables
No, you said 2005-04 ;) Matt means: could it be a typo?
Offline