Friday 16 May 2014

Cara panggil Codeigniter Controller Methods dari dalam View

Cara memanggil CI Controller method dari fail View.
Contoh class :


class Example extends CI_Controller {
   function __construct() {
      parent::__construct();
   }
   function show(){
      echo "show";
   }
}


Selepas itu, reassign Codeigniter object pada variable dalam fail View
$this->method_call =& get_instance();

Selepas itu, panggil controller method dalam fail View
$this->method_call->show();

Kod yang terhasil dalam fail VIEW adalah seperti berikut :
$this->method_call =& get_instance(); 
$this->method_call->show();


Selamat Mencuba.

source : HERE

Posted by : Marzuki Ahmad 

0 comments:

Post a Comment