Welcome Guest, Not a member yet? Register   Sign In
Having Touble With The Static-Pages Tutorial
#1

[eluser]Unknown[/eluser]
Hi,

I'm having trouble with the tutorial I found in the user guide.

I'm using LAMP under Ubuntu 11.04 and as far as I can tell everything is install and configured correctly on the lamp side of things.

I have made a test.php;

Code:
<?php phpinfo(); ?>

I placed this file in the root of the domain and when I execute it, I get the expected results.


I made the controller file application/controllers/pages.php which included the following code;

Code:
<?php

class Pages extends CI_Controller {

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

}
}


I then made the header template application/views/templates/header.php which included the following code;

Code:
<html>
<head>
<title><?php echo $title ?> - CodeIgniter 2 Tutorial</title>
</head>
<body>
<h1>CodeIgniter 2 Tutorial</h1>


Next I made application/views/templates/footer.php with the following code;

Code:
<strong>&copy; 2011</strong>
&lt;/body&gt;
&lt;/html&gt;


I then created application/views/pages/home.php and application/views/pages/about.php which contain the following code;

Code:
home
and
Code:
about


I then went back to application/controllers/pages.php and added the the following code;

Code:
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);

}

So the file now looks like this;

Code:
&lt;?php

class Pages extends CI_Controller {

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

}

Now, when I browse to 127.0.0.1/index.php/pages/view I get a blank page, no 404, no error message at all, just a white screen.

I'm stuck as to what to try now, I have gone over and over the code but can't find any issues.

Can anybody see what I have done wrong or perhaps have some advice where/what to check next?

Cheers
#2

[eluser]solid9[/eluser]
Better rename this,
Code:
public function view($page = 'home')

to this,
Code:
public function home_page$page = 'home')

I think 'view' is a reserved word for CI.

If that's not solved your problem.
check your error log.


#3

[eluser]Aken[/eluser]
There's an error, but error display is turned off. Google around for "PHP blank page" and you'll find explanations for how to turn it on.

And by the way, "view" is not a reserved controller name - should be able to use it no problem.
#4

[eluser]Unknown[/eluser]
[quote author="Aken" date="1349829752"]There's an error, but error display is turned off. Google around for "PHP blank page" and you'll find explanations for how to turn it on.

And by the way, "view" is not a reserved controller name - should be able to use it no problem.[/quote]

Cheers mate, got the errors showing now and making (slow) progress.




Theme © iAndrew 2016 - Forum software by © MyBB