Welcome Guest, Not a member yet? Register   Sign In
best way to do the following:
#1

[eluser]natefons[/eluser]
so lets say i have 3 (or even 100) different view "templates" that get used in different controller.

currently, most repetitive work (like say a menu, or other elements that might change in the future, but will be consistent through out all the views), i have placed in to a helper function, and i would call the helper to grab the data.

for example:
helper:
Code:
function menu()
{
  $data="<a href="#">Home</a> <a href="#">About</a>
  //etc etc etc

return $data
}

now when i need to display the menu on a view, i would just either put
menu(); on the view itself, or pass it to a variable in the controller.

i have also seen people put repetitive work like menus on a seperate view, and then load the data to a variable on the controller:
$data['menu']=$this->load->view('menu');


my question is, what is the more preferred method/fastest/etc etc
#2

[eluser]WanWizard[/eluser]
Use a template library, and define a separate view that contains the html for the menu.
You should keep layout out of you code as much as possible, this is what views are for.




Theme © iAndrew 2016 - Forum software by © MyBB