I’m just getting familiar with Codeigniter (2.1.0) and building a simple site, that has a table for products and a table for locations. I have followed the CI documentation and successfully built a page to display data from each table. But my goal is to show both sets of data on the home page. CakePHP handles this nicely with “elements”, where the data from an unrelated controller can be shown on a page handled by a different controller. Seems simple and I’m having a tough time finding a starting point.
Here is the index function from the products controller:
public function index()
{
$data['product'] = $this->product_model->get_product();
$data['title'] = 'title of page';
$this->load->view('templates/header', $data);
$this->load->view('product/index', $data);
$this->load->view('templates/footer');
}
I gave a shot to include the locations model by creating a function that called that model also in the products controller, and then included the function in the above with $this->functionName();
That did not work. Any advice on where to begin?
here is procedure to include the model
yes it is possible you can include model as you can