CodeIgniter Forums
Handling partial loads from the controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Handling partial loads from the controller (/thread-9081.html)



Handling partial loads from the controller - El Forum - 06-11-2008

[eluser]Aria Rajasa[/eluser]
I am sorry if this question have been posted, but i've search regarding partials and have not succeeded in finding them, so here goes..

I have inclue a view under a view like this (in my view/layout/default.php)

Code:
..
<div id="topbarleft">
&lt;?= $this->load->view('elements/main_menu');?&gt;
</div>
..

And i would like it if i can enable and disable the loading of that 'elements' in the controller (like the Elements plugin in cakePHP). Maybe something like this in a controller:

Code:
..
function test_method() {
$this->loadElements(array('a', 'b', 'c');
..

With a, b, c as the name of the elements. And of course in the view, i can count it like in Joomla. maybe like this:

Code:
..
if($this->elements-count('a') > 0) {
//display something
}
..

Is there a good way to do it? Thank you so much for further help.