A view controls how the user sees your website. Views make it easy for you to present a consistent interface, and to change it if you need to. One of the advantages of MVC is that you separate presentation from logic, keeping everything much cleaner.
So far, all we've done is look at the very simple welcome
view that installs out-of-the-box when you first load CI (See Chapter 3). Now let's see how to make it more elaborate.
A view is just a set of HTML shelves to hold your content. The shelves may be in any color. There may be lot of little ones or just a few widely-spaced elegant ones. But the view doesn't know or care what data is on those shelves, it is only interested in presentation.
As we saw in the previous chapters, views are created in ./application/views
and usually they have a .php
extension (but you can put whatever extension you want, only remember to write the extension when loading the view if it is not .php
).
First, to create a view, you need to create a skeleton...