Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-12-07 20:36:36
- damunoz
- New Member
- Registered: 2009-12-07
- Posts: 1
Getting parameters from URL
Hello,
I have this situation, I need a printer friendly page, so when I click on Print page I will pass in the URL a param, that I would pick up in the destination page:
The destination URL is the following:
http://www.cocinandocontiaflorita.tv/receta_pescado_marisco/pescado-a-la-peperonata?imprimir=si
On the destination page I have the following code:
<txp:php>
global $HTTP_POST_VARS;
$imprimir = $HTTP_POST_VARS[“imprimir”];
variable( array(‘name’ => ‘imprimir’, ‘value’ => $imprimir) );
echo “imprimir is $imprimir”;
</txp:php>
Then I would use:
<txp:if_variable name=“imprimir” value=“si”>
to change the front ent to make it friendly.My problem is that $imprimri is always empty, I cant seem to get the imprimir=si from the URL.
Any suggestions? I would really apreciate it.
daniel
Offline
Re: Getting parameters from URL
You are better with gps()
.
<txp:variable name="imprimir" value='<txp:php> echo gps("imprimir"); </txp:php>' />
Or, for example, with rah_function:
<txp:variable name="imprimir" value='<txp:rah_function call="gps" get="imprimir" />' />
Offline
Re: Getting parameters from URL
damunoz
Or you could take a look at the adi_gps plugin. It does exactly what you want without resorting to PHP code; it assigns the contents of all URL params (or any named vars if you prefer) to txp:variables so you can use them in your pages. Hope that helps.
Last edited by Bloke (2009-12-07 20:58:17)
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
Pages: 1