Sat, June 10, 2023
https://devcodepro.comdevcodepro
Home · Latest · Trends
17

How to get the current url in smarty

How to get the current url in smarty file
{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}
AD ยท www.interserver.net/r/240055 

Interserver | Standard & VPS Cloud Hosting | $2.50 /Month

Flexible VPS hosting platform to deploy your online projects. Economical and balanced between processor cores, memory and storage
rated 21 times (19) (2)
comments: 1 / hits: 8743  / 7 years ago, sat, sep 10, 16, 03:19:13
More From » PHP
 

Comments

7
php file:
Code:
$link =  "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$smarty->assign('link',$link);


template file:
Code:
{$link}
[#5] Tuesday, April 25, 2017, 8:59:48
 
info
commented 6 years ago
Only authorized users can post. Please sign in first, or register a free account
Login with Google
 
Share
Posted
Michael
Member since Sep 10, 2016
Total Code Snippets: 5
Total Comments: 0
Location: n/a
Michael snippets
7 years ago, sat, sep 10, 16, 3:07:57
// libs/plugins/modifier.sortby.php: <?php # sorts an array of named arrays by the supplied fields # code by dholmes at jccc d0t net # taken from http://au.php.net/function.uasort # modified by cablehead, messju and pscs at http://www.phpinsider.com/smarty-forum function array_sort_by_fields(&$data, $sortby){ static $sort_funcs = array(); if (empty($sort_funcs[$sortby])) { $code = "$c=0;"; foreach (explode(',', $sortby) as $key) { $d = '1'; if (substr($key, 0, 1) == '-') { $d = '-1'; $key = substr($key, 1); } if (substr($key, 0, 1) == '#') { $key = substr($key, 1); $code .= "if ( ( $c = ($a['$key'] - $b['$key'])) != 0 ) return $d * $c;n"; } else { $code .= "if ( ($c = strcasecmp($a['$key'],$b['$key'])) != 0 ) return $d * $c;n"; } } $code .= 'return $c;'; $sort_func = $sort_funcs[$sortby] = create_function('$a, $b', $code); } else { $sort_func = $sort_funcs[$sortby]; } @uasort($data, $sort_func); } # # Modifier: sortby - allows arrays of named arrays to be sorted by a given field # function smarty_modifier_sortby($arrData,$sortfields) { array_sort_by_fields($arrData,$sortfields); return $arrData; } ?> // Usage: {foreach from=$results|@sortby:"itemid" item=foo} {$foo.text} {/foreach}
comments: 2 / hits: 7760
PHP
7 years ago, sat, sep 10, 16, 3:13:33
<?php // index.php if(isset($_POST['submit'])) { if(get_magic_quotes_gpc()) { $domainname = htmlspecialchars(stripslashes($_POST['domainname'])); } else { $domainname = htmlspecialchars($_POST['domainname']); } if(!filter_var(gethostbyname($domainname),FILTER_VALIDATE_IP)) { echo "false"; } else { echo "true"; } } else { ?> <form method="post" action="index.php"> Domain Name<br /> <input class="input" placeholder="example.com" name="domainname" type="text" /><br /> <br /> <input type="submit" value="Submit" name="submit" /> </form> <?php } ?>
comments: 0 / hits: 3536
PHP
7 years ago, sat, sep 10, 16, 3:16:20
<?php $info = new ZipArchive(); $info->open('file.zip'); for($i = 0; $i < $info->numFiles; $i++ ){ $files = $info->statIndex($i); echo '<pre>'; print_r(basename($files['name'])); echo '</pre>'; } ?>
comments: 0 / hits: 3877
PHP
6 years ago, tue, feb 21, 17, 2:06:26
<?php $url = 'http://example.com'; $favicon = "https://www.google.com/s2/favicons?domain=".$url; if($favicon == false) { $newimage = "0"; } else { $extension = "png"; $time = date("ymdHis"); $newimage = $time.".".$extension; $destination = "uploads/".$newimage; if(@file_put_contents($destination,file_get_contents($favicon))) { echo "true"; } else { $newimage = "0"; } } ?>
comments: 0 / hits: 2923
PHP