Srini
Srini

Reputation: 387

Codeigniter: call a function in View From Controller


I am New to Codeigniter. In my Sample Application I add a new Tab called "RegForm" in my Main.php(View Folder). When i Click the RegForm Tab it load the New Window(width='800px' height='500px'). i understand the concept but i dont know how to write coding in Codeigniter. Basicall i call a function in Controller file when i Clicked the RegForm tab. and i need to call a function in View where i load a window with properties. amm i correct.

Upvotes: 0

Views: 7854

Answers (1)

Damien Pirsy
Damien Pirsy

Reputation: 25435

YOu could do this (if I understood correctly):

View 'someview' contains this link:

$atts = array(
              'width'      => '800',
              'height'     => '500',
              'scrollbars' => 'yes',
              'status'     => 'yes',
              'resizable'  => 'yes',
            );
echo anchor_popup('mycontroller/mymethod','Click this for a popup',$atts);

(anchor_popup is a funcion in the URL helper, just autoload it, it's really useful)

in Controller 'mycontroller':

class Mycontroller extends CI_Controller {

    //function index()
    // other functions

    function mymethod() 
    {
      $this->load->model('mymodelforthis');
      $data['properties'] = $this->mymodelforthis->get_properties();
      $this->load->view('myview',$data);
    }
}

THen, in 'myview', you display $properties the way you want Hope this helps, lmk

Upvotes: 1

Related Questions