Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
smarty.get parameters of an URL to display

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
tomtom83
Smarty n00b


Joined: 07 Feb 2012
Posts: 2

PostPosted: Tue Feb 07, 2012 12:50 pm    Post subject: smarty.get parameters of an URL to display Reply with quote

Hello,

I've tried to catch parameters of my URL
Code:
index.php?q=word1+word2
because I want to display them in a sidebar.

Therefore I assigned a new variable:

Code:
{assign var="words" value="+"|explode:$smarty.get.q}


Then I'm not sure how to do it, I tried this:

Code:
{foreach from=$words item=word}
{if !empty($smarty.get.q)}

<li>{$word}</li>

{/if}
{/foreach}


But it doesn't fit really, cause it displays the whole parameters like this:
Code:
<li>word1 word2</li>


I wanted to have a list item for every word, like this:

Code:
<li>word1</li>
<li>word2</li>


Can you give me a hint? What do I do wrong?

Thanks in advance!

Regards,
Thomas[/list]
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 698
Location: Germany, border to Switzerland

PostPosted: Tue Feb 07, 2012 1:56 pm    Post subject: Reply with quote

{$smarty.get.q} is the same as $_GET['q']. Values in $_GET are already urldecoded. So your "+" doesn't exist. It's become a space, of which + is the encoded representation.

Code:
{$words = " "|explode:$smarty.get.q}
{foreach $words as $word}
  <li>{$word|escape}</li>
{/foreach}


I'd suggest you do that exploding (trimming and sanitizing!) of $_GET['q'] in php, though. that's where that sort of stuff actually belongs
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
tomtom83
Smarty n00b


Joined: 07 Feb 2012
Posts: 2

PostPosted: Tue Feb 07, 2012 3:19 pm    Post subject: Reply with quote

Yeah!
It works! Thx!!

The plus was it. Just replaced it with a space Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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