Welcome Guest, Not a member yet? Register   Sign In
Beginner : call a controller within a view
#1

[eluser]FordEscort[/eluser]
I have three views :
- header_view
- home_view
- dynamic_menu_view

and two controllers :
- home_controller
- dynamic_menu_controller

I load the home_view by calling home_controller.
I include the header_view in home_view, and in the header_view I'd like to call the dynamic_menu_controller to load the dynamic_menu_view.

I know I can do this by simply writing $this->load->view('dynamic_menu_view') in the header_view, but I want a separated controller which will generate the data for the menu.
I've already seen something like this somewhere in the forum but I don't remember where.

Can you help me please?
Thanks.
#2

[eluser]rogierb[/eluser]
You cannot call a controller from a view(except through ajax). You can call helper functions so I suggest you change your dynamic_menu_controller in a dynamic_menu_helper.

Also it is not the MVC way.
#3

[eluser]FordEscort[/eluser]
OK. Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB