Welcome Guest, Not a member yet? Register   Sign In
(mvc theory) should a controller call *only* one view.php?
#5

[eluser]esra[/eluser]
[quote author="gavincali" date="1189216822"]My question: Should my controller (browse.php) be able to choose from the 12 or so view files to call directly -OR- should it only call it's mate-view (browseview.php), and let this mate-view act as a traffic-cop to the other view includes?[/quote]

Browseview can be the default view loaded by your index() method. You could have other methods in your controller that load other views and use redirect() in URL helper to load them where appropriate. Read the CI user guide sections describing how the segments in your url allow you to route to a specific controller and a method within that controller. Read the section on routing to learn how you can create an alias (route) which automatically redirects to a certain controller/method/. This should get you through the initial learning curve. Once you get accustomed to using segments, it's much more efficient than using something like a case statement to load various views.

EDIT: It's also possible for a controller to display multiple views at the same time on its own or via AJAX calls. For example, many IDEs allow you to search through all the files in a project using a Find in Files command. The search results are displayed in a separate view. It's possible to mimic the same sort of functionality with CI.


Messages In This Thread
(mvc theory) should a controller call *only* one view.php? - by El Forum - 09-08-2007, 10:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB