EllisLab text mark
Advanced Search
     
Problem when using Tutorial Code
Posted: 20 November 2012 07:26 PM   [ Ignore ]
Joined: 2012-11-20
1 posts

I have just started using CodeIgninter and have been looking at the documentation. My problem is with the following code from the tutorial. When I call it as is, I only get the 404 page. If I remove the ! the correct page displays. So obviously the page exists and can be found by the code.

What am I missing?

Jeff

public function view($page = ‘home’)
{
 
if ( ! file_exists(‘application/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);

}

 
Posted: 20 November 2012 08:07 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

Did you create the application/views/pages/home.php

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 20 November 2012 09:13 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-28
2435 posts

Did you rename and/or move your application or views folder? You’ll notice that the if() check has a hardcoded path - if that path is changed, you’ll need to update it appropriately.

 
Posted: 20 November 2012 09:19 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3796 posts

or use the APPPATH constant instead of ‘application’

 Signature