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

{ppurl} not parsing tpl vars

 
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 -> Bugs
View previous topic :: View next topic  
Author Message
ilir
Smarty Rookie


Joined: 20 Apr 2003
Posts: 16
Location: NYC

PostPosted: Fri Apr 25, 2003 1:31 pm    Post subject: {ppurl} not parsing tpl vars Reply with quote

Hi everybody,


I'm using {ppurl} to pass along my URL stuff to a link but it doesn't seem to parse tpl vars into the URL. This is my code:

Code:

{assign var="fltNum" value="124"}
<a href="{ppurl key="action" value=p3la key="flt" value="$fltNum"}">Action</a>


But this only displays:
Quote:
http://XXX.XXX.XXX.XXX/index.php?departure=ZRH&depdateDay=25&depdateMonth=05&depdateYear=134&desdateDay=25&desdateMonth=06&desdateYear=2003&destination=JFK&action=swo5&trvtype=roundtrip


As you can see, there is no "flt" key added to the URL. I think this is a problem with the plug-in because I tried placing the "key='flt' value=$fltNum" in front of the other key (action) but, then, I get the "action" key to display but not the "flt" key.

I know, this is complicated. But does anyone know of a workaround for this?

Thanks a bunch,

Ilir.
_________________
The real problem is not whether machines think but whether men do.
- B. F. Skinner
Back to top
View user's profile Send private message MSN Messenger
alan
Smarty Regular


Joined: 17 Apr 2003
Posts: 43

PostPosted: Fri Apr 25, 2003 3:46 pm    Post subject: Reply with quote

This code appears to be working (based loosly on ppurl)...

Code:
<?php

function smarty_function_url( $params, &$smarty )
{
   if (!isset($params['href']) || !is_string($params['href']))
   {
      // oops !

      return;
   }

   list($href, $args) = split("\?", trim($params['href']));

   $href = trim($href);
   $args = trim($args);

   if (empty($args))
   {
      $args = array();
   }
   else
   {
      $temp = explode("&", $args);
      $args = array();

      for ($i = 0; $i < count($temp); $i++)
      {
         list($name, $value) = split("=", $temp[$i]);

         $args[$name] = $value;
      }
   }

   $keys = array_keys($params);

   for ($i = 0; $i < count($keys); $i++)
   {
      if ($keys[$i] != "href")
      {
         $args[$keys[$i]] = $params[$keys[$i]];
      }
   }

   $result = $href;

   if (count($args) > 0)
   {
      $keys = array_keys($args);
      $temp = array();      

      for ($i = 0; $i < count($args); $i++)
      {
         $temp[] = $keys[$i] . "=" . $args[$keys[$i]];
      }

      $result .= "?" . implode("&", $temp);
   }

   echo $result;
}

?>
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 -> Bugs 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