|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
navid_gh Smarty Rookie
Joined: 16 Oct 2008 Posts: 6
|
Posted: Thu Oct 16, 2008 9:59 am Post subject: Add var to get url |
|
|
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 |
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
Posted: Fri Oct 17, 2008 6:21 am Post subject: |
|
|
Thx for this useful information ... |
|
Back to top |
|
navid_gh Smarty Rookie
Joined: 16 Oct 2008 Posts: 6
|
Posted: Wed Oct 22, 2008 11:54 am Post subject: |
|
|
Your Welcome |
|
Back to top |
|
|
|
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
|