Professional CodeIgniter, Thomas Myer

Chapter 3: A 10,000 - Foot View of CodeIgniter
68


Controllers
For simplicity ' s sake, you ' re going to use the default controller, welcome.php, for the first part of this
project. As things progress, you can create additional controllers as needed.

When you look at your project notes, you know that the following main destinations are required by
your application:
A home page


A Category page, showing subcategories


A subcategory page, showing products


A Product Detail page


A Shopping Cart page


A Search Results page


Various other minor pages, such as Contact Us, About Us, and Privacy Policy

Each of these destinations becomes a function of your controller. If you want users to visit an about_us
page on your site, you need an
about_us

function in your controller. Right now you don ' t care about the
details of what happens at those destinations; you just want to sketch them in, without regard to loading
models, views, helpers, or anything else.

Your primary goal right now is to get an overview of the project space, so you open the default welcome
.php controller in /system/application/controllers/ and get to work:
class Welcome extends Controller {
function Welcome(){
parent::Controller();
}
function index(){
//use this for your home page
}
function cat(){
//use this for the category page
}
function subcat(){
//use this for the subcategory view
}
function product(){
//use this for the product view
}
function cart(){
//use this for the shopping cart view
}
c03.indd 68
c03.indd 68
6/10/08 5:33:53 PM
6/10/08 5:33:53 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.