CodeIgniter Forums

Full Version: Header not appearing & Footer not correct
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've followed the instructions in the Tutorial on the Static Page but the Header does not appear although the tab is labelled "CodeIgniter Tutorial" and the content of the Footer appears on the same line as the content of the Page.

Is there some obvious reason for this malfunction?

*************
This is the content of my Pages.php - application/controllers/Pages.php
Code:
<?php
class Pages extends CI_Controller
{
       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);
       }
}
This is the content of my header.php - application/views/templates/header.php
Code:
<html>
       <head>
               <title>CodeIgniter Tutorial</title>
       </head>
       <body>

               <h1><?php echo $title ?></h1>
This is the content of my footer.php - application/views/templates/footer.php
Code:
                <em>&copy; 2014</em>
       </body>
</html>
This is the content of my routes.php - application/config/routes.php
Code:
$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
This is one URL http://localhost/MyProject/index.php/pages/view

And this is the result;

Home

Hello World! © 2014

And this is the other URL http://localhost/MyProject/index.php/pages/view/about

And this is the result;

About

Hello World! © 2014

I've checked every page numerous times, tried re-booting, and tried another browser, all to no avail.

Can somebody explain where I'm going wrong?
I created a file at application/views/pages/CodeIgniter Tutorial.php

and changed

Code:
public function view($page = 'home')
to
Code:
public function view($page = 'CodeIgniter Tutorial')

in Pages.php and changed

Code:
<em>&copy; 2014</em>
to
Code:
<p><br><br><em>&copy; 2014</em></br></br></p>


in footer.php

I can achieve close to my expectations and now realise my expectations were far too much for a simple piece of coding.

If the CodeIgniter Tutorial was amended accordingly it would be much easier to understand.