First CI site -> Question regarding controllers for pages |
[eluser]rt30000[/eluser]
Hello. I am working on on my first CI (actually my first MVC usage as well) site and I believe I am making good progress. One question I have before proceeding too far, is about controllers/pages. I understand how they work with views, etc. I just question whether I am using them correctly. For example, i have a site with ~5 pages each with many subpages. Is it correct to have 5 controllers (for each section)? My pages are using multiple views, and is not yet hooked up to a db so pardon all the fields. This approach works, just not sure if it is best pracitices. Seems like alot of repetitive code when I get into many subpages. A sample of the products and products/cheese page code (controller) Code: <?php If I am not explaining this clearly, fire away any questions! Thank you for any help. So far I think I will really benefit from using this framework. Thanks!
[eluser]crumpet[/eluser]
you can call views from within views so you can have a view file called "loader.php" which calls hte header, and then the nav, and then the content and then the footer etc... i usually make a function in my controller like this Code: function _run($view){ Code: //loader.php Then the functions in my controller don't call $this->load->view() instead tehy call $this->_run() |
Welcome Guest, Not a member yet? Register Sign In |