Welcome Guest, Not a member yet? Register   Sign In
Basic Tutorial Help
#1

I am working with the simple tutorial in the documentation. 

Create a file at application/controllers/Pages.php with the following code. 




<?php
class Pages extends CI_Controller {

       public function view($page = 'home')
       {
       }
}




And this I am not sure if it goes in the Pages.php file or a new one, and if new I don't see the name of it and where it goes, that is which folder. Also, I do not see a closing ?> php tag in any of this code.




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





Sorry, I am very new to CodeIgniter and actually php to be honest. I have tried adding the code to the Pages.php file but only get error's.

Is there a completed version somewhere so I can see what I am doing wrong?

Thanks for any help!
Reply


Messages In This Thread
Basic Tutorial Help - by in2tech - 12-27-2016, 11:59 PM
RE: Basic Tutorial Help - by InsiteFX - 12-28-2016, 05:52 AM
RE: Basic Tutorial Help - by in2tech - 12-28-2016, 10:49 AM
RE: Basic Tutorial Help - by InsiteFX - 12-29-2016, 04:37 AM
RE: Basic Tutorial Help - by in2tech - 12-30-2016, 12:23 AM
RE: Basic Tutorial Help - by in2tech - 12-31-2016, 01:45 PM
RE: Basic Tutorial Help - by InsiteFX - 01-01-2017, 03:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB