Can't understand how to use the view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Can't understand how to use the view (/showthread.php?tid=20811) |
Can't understand how to use the view - El Forum - 07-22-2009 [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: Can't understand how to use the view - El Forum - 07-22-2009 [eluser]GSV Sleeper Service[/eluser] this diagram should help you understand when and how to use views. http://ellislab.com/codeigniter/user-guide/overview/appflow.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 Can't understand how to use the view - El Forum - 07-22-2009 [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 Can't understand how to use the view - El Forum - 07-22-2009 [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 |