CodeIgniter Forums
Newbie question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forum-10.html)
+--- Thread: Newbie question (/thread-74111.html)



Newbie question - ronniebel - 07-23-2019

I'm a complete newbie and going through the CodeIgniter tutorial at this link.

https://www.codeigniter.com/user_guide/tutorial/static_pages.html

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? 

application/controllers/Pages.php

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

        $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.

Ron


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.