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
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:
function.site_url.php
<?php
functionsmarty_function_site_url($params,&$smarty)
{
//check if the needed function exists//otherwise try to load itif (!function_exists('site_url')) {
//return error message in case we can't get CI instanceif (!function_exists('get_instance')) return"Can't get CI instance";
$CI= &get_instance();
$CI->load->helper('url');
}
if (!isset($params['url'])) returnbase_url();
elsereturnsite_url($params['url']);
}
?>
function.base_url.php
<?php
functionsmarty_function_base_url($params,&$smarty) {
if (!function_exists('base_url')) {
//return error message in case we can't get CI instanceif (!function_exists('get_instance')) return"Can't get CI instance";
$CI= &get_instance();
$CI->load->helper('url');
}
returnbase_url();
}
?>
Installation: just drop these two files in smarty’s plugin folder.