CodeIgniter Forums
Newbie question - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: Model-View-Controller (
+--- Thread: Newbie question (/showthread.php?tid=74111)

Newbie question - ronniebel - 07-23-2019

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);

RE: Newbie question - InsiteFX - 07-23-2019

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.

RE: Newbie question - ronniebel - 07-24-2019

Got it. Thanks for all your help.


RE: Newbie question - InsiteFX - 07-24-2019

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.