Can't understand how to use the view |
[eluser]miauksius[/eluser]
Hi everyone, I have a problem, I don't understand, when and how do I have to use the view. Before starting coding php oop (i mean withoust using classes), i was coding my pages like this: Code: <?php Can you please explain me, or give me a link to some tutorial that would explain how to fit that output to a view? Thank you. P.S. Sorry for the broken english :red:
[eluser]GSV Sleeper Service[/eluser]
this diagram should help you understand when and how to use views. http://ellislab.com/codeigniter/user-gui...pflow.html to fit that output to a view you will need a controller and a view. One important concept to understand when using CI is that by default $_GET no longer exists, you pass data from the URL using the URI class, or by using parameters for your controller methods. quick and dirty example Code: // controllers/foo.php read the manual, then read it again, go outside for a bit, then read the manual once more
[eluser]miauksius[/eluser]
OK, that was easy enough to understand, thanks but one more example (this version is without classes), let's say I have a guestbook.php file, and it contains something like that: Code: <?php How should the "post" id look in the view? Should I create two views: one with inputs and other to display result? Or somehow I could fit these two to one view by passing them different data to display (or maybe that's impossible?)? I have readed the manual several times, studyed a few projects which were coded on CI, but for me as a newbie it's quite hard to understand how to use it wisely, that the code would be very tidy. I know how to get sent data by user, today I made myself a guestbook on CI, but the code is very messy
[eluser]Johan André[/eluser]
Dude! This is covered in the screencast on the codeigniter site and in the userguide. Codeigniter favors the MVC-pattern. Read up on MVC the userguide. It's really not that hard. There are alot of tutorials spread over the net too... Basics: Controller handles logic Models handles data Views handles the output to screen |
Welcome Guest, Not a member yet? Register Sign In |