Welcome Guest, Not a member yet? Register   Sign In
Stuck at the second hurdle
#1

[eluser]CodeIgNewbie[/eluser]
I've managed to get Code Igniter installed (which is an achievement), but following the tutorial "Tutorial − Static pages" I find that I can't get any page to render. I've created the header and footer files, and the home and about files (yes, all in the right directories), but nothing shows in http://www.trainstormbeta.co.uk/ci/index.php/pages/view

I think my main concern is the code:

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

}

Where should this go?? I'm really confused.

Sorry for the basic nature of this issue, but until I know what's going on, I'm just stuck!
#2

[eluser]soup7[/eluser]
make sure this file exists...

application/views/pages/home.php

if that "home.php" file does not exist, the 404 is thrown.

here's where they're accessed/viewed:
example.com/index.php/home

or, depends where you have codeigniter installed....

example.com/codeigniter/index.php/home

or

example.com/codeigniter/index.php/about (for your about page)
#3

[eluser]CodeIgNewbie[/eluser]
Thanks for the quick response.

The file "exists" in the application/views/pages folder, but a 404 is thrown when I try to access http://www.trainstormbeta.co.uk/ci/index.php/home.

Have I forgotten to configure something? I just followed another tutorial, but I'm getting the same result. This is very frustrating.
#4

[eluser]soup7[/eluser]
i did not see your 'extends' portion of your pages.php file you pasted...

the pages.php file (in your controller dir.) should be... (all of this

<?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);
}
}
?>
#5

[eluser]CodeIgNewbie[/eluser]
Still the same result. Realised that the c&pasted; quotes needed rescripting, but still no joy.
#6

[eluser]soup7[/eluser]
i don't see it, w/o all the code to see (and for me that includes typos/etc, i make them all the time) everything looks ok.
#7

[eluser]CodeIgNewbie[/eluser]
I notice in the main index file that there's a call: require_once BASEPATH.'core/CodeIgniter.php';

I don't have this in my CORE dir. Where can I find this file and why isn't it in the zip file? Is it not required??
#8

[eluser]CodeIgNewbie[/eluser]
OK, got it working. If you hadn't pointed out that the code block in the tutorial needed to go in the pages file I'd have been scuppered. It's ambiguous there.

Thanks for your help. I'm flying now!
#9

[eluser]soup7[/eluser]
here's where i'm lost, i got to the end of the news tutorial and everything works except i can not view an individual news item, i get a 404 message; i can view them all, and even add a new one. but if i click 'view article', i get 404 error.
#10

[eluser]CodeIgNewbie[/eluser]
You'll have to wait until I catch up. I thought you were an expert at this. Perhaps we can scrap along together :o)




Theme © iAndrew 2016 - Forum software by © MyBB