Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-08-25 21:23:53

jpea
New Member
From: minnesota, usa
Registered: 2006-06-16
Posts: 7
Website

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

#2 2006-08-25 21:52:51

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,125
Website GitHub

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

#3 2006-08-26 09:41:42

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,393
Website GitHub Mastodon

Re: pass variable through url string

Offline

#4 2006-08-26 13:14:36

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,674
GitHub Twitter

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

#5 2006-08-26 13:58:07

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,393
Website GitHub Mastodon

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']).
  '&amp;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

#6 2006-08-26 14:57:25

jpea
New Member
From: minnesota, usa
Registered: 2006-06-16
Posts: 7
Website

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

#7 2006-08-26 15:41:41

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,674
GitHub Twitter

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

#8 2006-08-28 17:26:57

jpea
New Member
From: minnesota, usa
Registered: 2006-06-16
Posts: 7
Website

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

#9 2006-08-28 17:31:04

Walker
Plugin Author
From: Boston, MA
Registered: 2004-02-24
Posts: 592
Website

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

#10 2006-08-28 17:35:01

jpea
New Member
From: minnesota, usa
Registered: 2006-06-16
Posts: 7
Website

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

Board footer

Powered by FluxBB