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

Add var to get url

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


Joined: 16 Oct 2008
Posts: 6

PostPosted: Thu Oct 16, 2008 9:59 am    Post subject: Add var to get url Reply with quote

hi
first i sorry for my bad english
please edit to common english tanx.

my plugin work for add var to get url
for example:
index.php?var1=value1
now if you will add another var with TEST name to this url, use this plugin:
index.php?var1=value1&TEST=value

return -> previous url with new variable that you added and create get_url varible for use in url

use -> {url_check text = 'ln=en' get_name = 'ln'}

in this use check exist (ln) variable in url and overwrite with value of text var (text = 'ln=en')

or {url_check text = 'ln=en'}
in this use not check exist (ln) variable in url and add value of text var (text = 'ln=en')

now plugin code:
Code:

<?php
/**
 * Smarty {url_check} function plugin
 *
 * Type:     function<br>
 * Name:     url_check<br>
 * Purpose:  check url for get method
 * @param Smarty
 */
 
 /**
 * Name:   Navid Ghahramani<br>
 * Email:  dreamlearn2005@yahoo.com
 */

function smarty_function_url_check($params, &$smarty)
{
   $url = $_GET;
   $add = $_SERVER['PHP_SELF'];
   if(strpos($add,"index.php")){
      $add = substr($add,0,strpos($add,"index.php"));
   }
   if(count($url)){
      foreach($url as $i=>$k){
         if($i != $params[get_name]){
            $get .= $i . "=" . $k . "&";
         }
      }
      $resualt = $add . "?" . $get . $params[text];
   }else{
      
      $resualt = $add . "?" . $params[text];
   }
    $smarty->assign('get_url', $resualt);
}
?>


and sample use:
Code:
               
{url_check text = 'ln=en' get_name = 'ln'}
<a href="{$get_url}">
<img src="test.gif" border="0" title="English Website"/>
</a>


tanx
good luck Very Happy
Back to top
View user's profile Send private message Send e-mail
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Fri Oct 17, 2008 6:21 am    Post subject: Reply with quote

Thx for this useful information ...
Back to top
View user's profile Send private message
navid_gh
Smarty Rookie


Joined: 16 Oct 2008
Posts: 6

PostPosted: Wed Oct 22, 2008 11:54 am    Post subject: Reply with quote

Your Welcome
Back to top
View user's profile Send private message Send e-mail
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 -> Plugins 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