Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
pass variable through url string
hi all, I searched a good deal for an answer but came up empty. is there any way to pass a variable to a different tp section through the url string? What I’m trying to do it call a window.open in a javascript function and pass a variable to the new page being opened. A url string seems to be my best option, but when I try to pass it it just opens my default section page. Any ideas?
Last edited by jpea (2006-08-25 21:24:31)
Offline
Re: pass variable through url string
I’m not quite sure exactly what it is you want to achieve or want to pass on, but possibly chs_ifurlvar or alternatively chs_cookie may be of help.
TXP Builders – finely-crafted code, design and txp
Offline
Re: pass variable through url string
Offline
Re: pass variable through url string
still an excellent advice Robert (as allways :) Thks!
So is it possible to pass the content of name input and surname input from zem_contact form to a “thank you message” form?
Thank you for your answer.
Cheers,
Patrick.
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: pass variable through url string
One could think of that:
on the sending page:
<txp:php>
global $zem_contact_form;
$url = 'http://www.example.com/article/thank-you/'.
'?name='.strip_tags($zem_contact_form['name']).
'&surname='.strip_tags($zem_contact['surname']);
echo '<a href="'.$url.'">Submit!</a>';
</txp:php>
on the receiving page (located at http://example.com/article/thank-you):
<p>Thanks, <txp:chs_urlvar_echo var="surname" /> <txp:chs_urlvar_echo var="name" />!</p>
Might work, not tested. In real life, you would sanitize both values a little bit more, I suppose.
Offline
Re: pass variable through url string
Thanks everyone :)
I think something more in the direction of mod_rewrite might be the right path, although I’m not sure how it might work. Anyone know if there’s something I can put in .htaccess to not make my default page come up when I attach more than the section name to the end of a url? I’ll check into the cookie also though.
Offline
Re: pass variable through url string
Woow so cool Robert!
Many Tks.
Have a good day.
Cheers,
Patrick.
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: pass variable through url string
ok, I feel dumb. For some reason it wasn’t working the first time I tried it so I thought it wasn’t possible :
<code>
<a href=“comments/?commentID=<txp:article_id />”, target=”_blank”><txp:article_id /></a>
</code>
and on the popped-up page :
<code>
<?php
$commentID = $_GET[‘commentID’];
echo $commentID;
?>
</code>
Offline
Re: pass variable through url string
is the popped up page rendered by textpattern or just a separate php file?
If so, you need to make sure you use <code><txp:php></txp:php></code> on the popup page or form.
Offline
Re: pass variable through url string
thanks walker. it’s a page in text pattern, so i’ll change it up with regards to using php.
Offline
Pages: 1