You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
World Wide Web Server edited this page Jul 4, 2012
·
6 revisions
Category:Help::TipsAndTricks
Some time ago I wrote some very small plugins for Smarty, which allow me to use CI’s URL helper functions (base_url() and site_url()) directly from my Smarty templates.
So I decided to share them:
[code]
function.site_url.php
<?php
function smarty_function_site_url($params,&$smarty)
{
//check if the needed function exists
//otherwise try to load it
if (!function_exists('site_url')) {
//return error message in case we can't get CI instance
if (!function_exists('get_instance')) return "Can't get CI instance";
$CI= &get_instance();
$CI->load->helper('url');
}
if (!isset($params['url'])) return base_url();
else return site_url($params['url']);
}
?>
[/code]
function.base_url.php
[code]
<?php
function smarty_function_base_url($params,&$smarty) {
if (!function_exists('base_url')) {
//return error message in case we can't get CI instance
if (!function_exists('get_instance')) return "Can't get CI instance";
$CI= &get_instance();
$CI->load->helper('url');
}
return base_url();
}
?>
[/code]
Installation: just drop these two files in smarty’s plugin folder.