Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

get url string

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
enhance
Smarty n00b


Joined: 24 May 2003
Posts: 3

PostPosted: Sat May 24, 2003 10:31 pm    Post subject: get url string Reply with quote

I have problem that I just can't figure out from smarty.

I have a url that appears something like this:

When someone goes here:
info.php?qstId=10&dat=foo

I need the "foo" to display in the template.

so anytime someone clicks on a link in the template,
"foo" stays in the url.

I basically need to include this somehow:

a href="info.php?qstId={$QuestionId}&dat={$dat}"

Thank You for any help,
Joe
Back to top
View user's profile Send private message
aloner
Smarty Rookie


Joined: 24 Apr 2003
Posts: 24

PostPosted: Sat May 24, 2003 10:36 pm    Post subject: Reply with quote

Maybe
{$smarty.get.qstId}
{$smarty.get.dat}
?

Smile
_________________
Your ad here.
Back to top
View user's profile Send private message
enhance
Smarty n00b


Joined: 24 May 2003
Posts: 3

PostPosted: Sat May 24, 2003 10:57 pm    Post subject: Reply with quote

I included that in the template and no luck.

this little problem is driving me insane, if someone could help or explain what to do. It would help me greatly.

Thanks,
Joe
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun May 25, 2003 12:43 am    Post subject: Reply with quote

hmmm, if aloner's solution didn't work, then this REALLY should work:

[php:1:97d15388b1]<?php
$smarty->assign( 'qstId', $_REQUEST['qstId'] );
$smarty->assign( 'dat', $_REQUEST['dat'] );
?>[/php:1:97d15388b1]

Code:

<a href="info.php?qstId={$qstId}&dat={$dat}">
Back to top
View user's profile Send private message
sweatje
Smarty Regular


Joined: 17 Apr 2003
Posts: 70
Location: Bettendorf, Iowa, USA

PostPosted: Sun May 25, 2003 2:31 am    Post subject: Reply with quote

Or sometimes I do:

[php:1:7d2ee91ccc]<?php
$smarty->Assign('selflink', $_SERVER['REQUEST_URI']);
php>[/php:1:7d2ee91ccc]

and
Code:
<a href="{$selflink}">foo</a>

_________________
Jason
jsweat_php AT yahoo DOT com
Back to top
View user's profile Send private message
enhance
Smarty n00b


Joined: 24 May 2003
Posts: 3

PostPosted: Sun May 25, 2003 4:09 pm    Post subject: thanks Reply with quote

thank you to all who replied and thanks to boots for the code. That prove to be the best method for me.
Back to top
View user's profile Send private message
Ze
Smarty Rookie


Joined: 13 Jun 2003
Posts: 5
Location: Rennes, France

PostPosted: Fri Jun 13, 2003 9:56 am    Post subject: how to get complete url Reply with quote

Hi,

I would like use in my templates the complete url of the current page (ie: http://www.site.com/idndex.php?arg=value&bar=foo)
Is there a way to get this url directly with a smarty feature ?
I have try {$smarty.get.page} but this display nothing...

Someone have an elegant solution for me ? Do i need to code a php function who return this url and use it on my template ?

Ze
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Jun 13, 2003 10:21 am    Post subject: Re: how to get complete url Reply with quote

Hi Ze:

Smarty provides access to the PHP $_SERVER (or $HTTP_SERVER_VARS as appropriate) superglobal.

You can probably use {$smarty.server.REQUEST_URI} as that is most likely what you need (note this returns the URI, not the URL). As you are probably aware, you could also get other values by using one of the keys described in the reserved variables page of the PHP manual. (of interest here: SERVER_NAME, HTTP_HOST and SERVER_PORT).

HTH


Last edited by boots on Fri Jun 13, 2003 2:29 pm; edited 1 time in total
Back to top
View user's profile Send private message
Ze
Smarty Rookie


Joined: 13 Jun 2003
Posts: 5
Location: Rennes, France

PostPosted: Fri Jun 13, 2003 1:37 pm    Post subject: Reply with quote

Thank you very much, i'm probably tired Smile. I have missed in the documentation that in {$smarty.get.page}, page is an argument of the exemple's URL .... I'm so stupid !

Thanks again for smarty's forum !

Ze
_________________
--
Yann RICHARD
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP