CodeIgniter Forums

Full Version: Newbie question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm a complete newbie and going through the CodeIgniter tutorial at this link.

When I get to the section "Adding logic to the controller, I don't understand what to do when it says "In order to load those pages, you’ll have to check whether the requested page actually exists:"  What am I supposed to do with the code below which is pasted below? Am I supposed to put it in the controller that I created just few lines above? 


public function view($page = 'home')
        if ( ! file_exists(APPPATH.'views/pages/'.$page.'.php'))
                // Whoops, we don't have a page for that!

        $data['title'] = ucfirst($page); // Capitalize the first letter

        $this->load->view('templates/header', $data);
        $this->load->view('pages/'.$page, $data);
        $this->load->view('templates/footer', $data);
It goes into your Pages.php Controller

IT is telling you by the application/controllers/Pages.php

All of the tutorial code will have something like that above the code
so that you know where to place it.
Got it. Thanks for all your help.

Just a note, when you get to the last part with the news section you will need
to create the Success web page yourself it's not in the manual and you will get
an Error on it.