Help in include files |
[eluser]mradlmaier[/eluser]
Hi Khuram, Although the User Guide is a bit short at some points you really should go through introductionary chapters. This will explains some of your questions. I am am also a newbie to CI, but I have worked with similar frameworks before... Quote:1. If a page has Header and Footer, do I make model-view-controller set for each of them.The footer, header, etc. stuff has nothing to do with the concept of model-view-controller. Footer, header, etc. go into the views. For Beginners, you should start by using only views and controllers. The controllers basically contain the logic of your application, while views ideally only displays the results. So your controller can 'include' different views. Quote:4. Can I use the Database class in these include (header,footer, category list) php files directly without going through MVC everytime.I think so, but database stuff should go in the controller and from there is passed tho the view. If you use a model, it actually represents your data in the application an see this thread: Quote:5. How to include these files in my main MVC page.There is no main MVC page. This is separated into Views, Controllers and, if you need it, Models. The reason to do this is that if you mixed them all in one page and later want to change a view or add a view, it is difficult todo. For example there could be a tree-like view and a table-like view of the data (the rows in a database table) and a view which displays a single row of your db table. All these three views display the same data (~Model) while, they allow for diffent user interactions on these views. Your controller handles these interactions (i.e. the click on a edit-button) and makes the changes to your data, either through your Model or directly (in a simple application you might choose to manipulate the dat directly) Quote:6. Since these file will be needed on more than one pages, how can I make them global with the option to include them at some places and not include them some places. A view can be called from different methods in a controller or even different controllers. Different data can be passed to the view. So views are global in a sense. I guess you should read some general stuff about the Model-View-Controller Design Pattern to clearly understand that. MVC is not specific to CI or PHP, all good frameworks and object-oriented languages use it. Quote:7. Where to put my CSS, Images and .js files. Should I put them on the document root.Put them in there own folders and allow access to these folders in .htaccess. There is an article in the wiki about it and a thread at: http://ellislab.com/forums/viewthread/96424/ Quote:8. The config variables I need like site title, contact us email etc. are going to be loaded from the database. How can I do that, I’m basically stuck with file inclusion and going through MVC for each step.They go in config files and can be loaded from there. Look at the User Guide for how to do that. Database would be bad for performance. DB is for data that changes, but not for configuration, which hardly ever changes. You really need to look at the user guide, most of your questions are answered there, and you should read some general stuff about MVC. It`s worth it, once you get yourself aquainted it will save you a lot of time... Michael |
Messages In This Thread |
Help in include files - by El Forum - 11-14-2008, 10:22 AM
Help in include files - by El Forum - 11-14-2008, 01:10 PM
Help in include files - by El Forum - 11-14-2008, 01:18 PM
Help in include files - by El Forum - 11-14-2008, 01:25 PM
Help in include files - by El Forum - 11-14-2008, 01:26 PM
Help in include files - by El Forum - 11-14-2008, 01:29 PM
Help in include files - by El Forum - 11-14-2008, 01:33 PM
Help in include files - by El Forum - 11-14-2008, 01:36 PM
Help in include files - by El Forum - 11-14-2008, 01:37 PM
Help in include files - by El Forum - 11-14-2008, 02:07 PM
Help in include files - by El Forum - 11-14-2008, 02:10 PM
Help in include files - by El Forum - 11-17-2008, 04:52 AM
Help in include files - by El Forum - 11-17-2008, 10:00 AM
Help in include files - by El Forum - 11-17-2008, 11:22 AM
Help in include files - by El Forum - 11-17-2008, 11:26 AM
Help in include files - by El Forum - 11-17-2008, 04:16 PM
Help in include files - by El Forum - 11-17-2008, 05:44 PM
|