Welcome Guest, Not a member yet? Register   Sign In
not able to fetch smarty tpl in xajax function
#1

[eluser]Unknown[/eluser]
Hi,


I facing problem in fetching a smarty tpl in xajax function

class User extends controller{
function index1() {
function test_function($data) {
$objResponse = new xajaxResponse();
//$objResponse->addAlert(print_r($data,true)Wink;
$this->mysmarty->assign('cc',"hello");
$content= $this->mysmarty->fetch('list.tpl');
$objResponse->addAssign("content","innerHTML", $content);
return $objResponse->getXML();
}

$this->load->library('xajax');
$this->xajax->registerFunction("test_function");

$this->xajax->processRequests();

$template['xajax_js'] = $this->xajax->getjavascript(null, '/js/xajax.js');


$this->mysmarty->assign('xajax_js',$template['xajax_js']);
$this->mysmarty->display("index.tpl");

}
}

It's giving error:-

FATAL ERROR:- Using $this when not in object content in line 20


kindly give solution , how can i fetch the other tpl, i have also tried to make object of the class

$user= new User;

using $user at place of $this;

still not working...............

thanks
#2

[eluser]mistress_shiira[/eluser]
what is mysmarty by the way?Smile or maybe u can try instantiating an instance of CI like this:
$CI = & get_instance();
and use it like so:
$CI->mysmarty->assign();
#3

[eluser]alpar[/eluser]
Don't forget that you can also call functions from objects with xajax. You can put your functions as controller methods. Prefix it with an _ (underscore) like _method and it can't be accessed directly. See the xajax docs on how you can call a method from a class (i think you have to use an array not sure haven't used xajax for a long time) and also do you have tor return $objResponse->getXML(); ? not just teh object? Not sure that's wrong just asking...




Theme © iAndrew 2016 - Forum software by © MyBB