Welcome Guest, Not a member yet? Register   Sign In
Header not appearing & Footer not correct
#1

(This post was last modified: 07-19-2015, 07:28 AM by christaliise.)

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?
Reply
#2

(This post was last modified: 07-21-2015, 08:25 PM by christaliise.)

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




Theme © iAndrew 2016 - Forum software by © MyBB