• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie question

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

https://www.codeigniter.com/user_guide/t...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);
}
Reply

#2
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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
Got it. Thanks for all your help.

Ron
Reply

#4
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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.