Join Jon Peck for an in-depth discussion in this video Generating output with a view, part of Up and Running with PHP CodeIgniter (2013).
- View Offline
A view is a partial or complete webpage. Designers like views because it's most…HTML with a very bar minimum in PHP code, and what logic is there are four hs and so forth.…Views can be embedded in other views, which allows for hierarchies and cleaner,…more reusable code. Even though they're webpages, a view…cannot be called directly. It can be only loaded by controller.…So with this context, let's get that HTML out of the controller and into a view.…
From NetBeans, I'm going to navigate to the Views directory.…Right now, there's only two files. The same placeholder index.html and…welcome message.php. Open welcome message.php to see what's inside.…Scrolling through, it's a complete html five page with no php whatsoever.…At the bottom there is one little anomaly. Page rendered in elapsed time in curly braces.…This is a pseudo variable from the benchmarking class...…I'll get into class libraries in a later chapter.…
For the time being, just close welcome message.…Then create a new file in views called magazines, plural, .php.…
Starting with the what and why of CodeIgniter, Jon introduces key concepts such as the MVC pattern and libraries by demonstrating how to create static pages, then storing and displaying magazine info in a database. Advanced topics like classes and helpers are explored to validate user input, upload files, and much more. By creating a complete system, you'll have the foundation to build your own applications with CodeIgniter.
- What is CodeIgniter?
- Creating a static page controller
- Generating output with a view
- What is a model?
- Saving data with Active Records
- Creating forms
- Validating user input
- Listing records in tables
- Uploading images
- Viewing and deleting records