CodeIgniter Forums
Best approach/method to pass array in View - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Best approach/method to pass array in View (/showthread.php?tid=47056)



Best approach/method to pass array in View - El Forum - 11-24-2011

[eluser]qpixo[/eluser]
Quick question: When building a website with dynamic contents and menu retrieving from db.

In the controller, I would have two methods to call one Model to get desire queries.
As for display in View, what is the best approach/method to optimize and to call them?

Can I simply call both in same View file?
or better declare 2 public global arrays?

Ex:
Code:
function method1() {
data[$tabMenu] = this->model->getAllMenu(...);
$this->load->view('my_view', $data);
}

function method2() {
data[$tabContents] = this->model->getContentByCategory(...);
$this->load->view('my_view', $data);
}