Welcome Guest, Not a member yet? Register   Sign In
How to call a helper from a template function
#1

[eluser]thekrow[/eluser]
Hello

For this project I'm using Smarty, I'm trying to create a template function that needs some functions contained in the URL helper. My Smarty library sits in myproject/applications/libraries/smarty and as you may know, my template function is in myproject/applications/libraries/smarty/libs/plugins.

Normally when I want to use CI resources (e.g. helper, library) I must create an instance of the class and then load my resource.

This time it doesn't work. I'm guessing the problem is because I need to include a file (codeigniter.php ? ) in my function.myfunction.php but I'm having trouble to get my function to work. Please look at the code below.

Code:
<?php
require_once '/system/core/codeigniter.php';

function smarty_function_fix_url($params, $template)
{
   $CI =& get_instance();
    
   $CI->load->helper('url');
    
   // Something else that I will write later
   //
   //
    
   return $CI->url->base_url();    
}

The error I'm getting is this

Code:
Fatal error: Cannot redeclare get_instance() (previously declared in C:\wamp\www\webnesis\fuel\codeigniter\core\CodeIgniter.php:208) in C:\wamp\www\webnesis\system\core\CodeIgniter.php on line 232

Any help will be appreciate it.




Theme © iAndrew 2016 - Forum software by © MyBB