ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Stuck at the second hurdle

February 25, 2013 9:51am

Subscribe [2]
  • #1 / Feb 25, 2013 9:51am

    CodeIgNewbie

    18 posts

    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 / Feb 25, 2013 12:59pm

    soup7

    11 posts

    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 / Feb 25, 2013 1:33pm

    CodeIgNewbie

    18 posts

    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 / Feb 25, 2013 1:56pm

    soup7

    11 posts

    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 / Feb 25, 2013 2:09pm

    CodeIgNewbie

    18 posts

    Still the same result. Realised that the c&pasted; quotes needed rescripting, but still no joy.

  • #6 / Feb 25, 2013 3:28pm

    soup7

    11 posts

    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 / Feb 25, 2013 4:01pm

    CodeIgNewbie

    18 posts

    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 / Feb 26, 2013 7:17am

    CodeIgNewbie

    18 posts

    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 / Feb 26, 2013 8:12am

    soup7

    11 posts

    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 / Feb 26, 2013 8:17am

    CodeIgNewbie

    18 posts

    You’ll have to wait until I catch up. I thought you were an expert at this. Perhaps we can scrap along together :o)

  • #11 / Feb 26, 2013 11:24am

    CodeIgNewbie

    18 posts

    Not got there yet, but I’m wondering if you rerouted in “application/config/routes.php”

    And if you did, does it need to be before, between or after the two existing elements?

    It’s really hazy when it tells you to “add code”. Where? Inside a function, outside, which file sometimes!! Annoying.

  • #12 / Feb 26, 2013 11:41am

    CodeIgNewbie

    18 posts

    I’m right there with you. The routing additions are typically ambiguous!! Don’t really know where to go from here. Let’s keep each other informed, OK?

  • #13 / Feb 26, 2013 11:43am

    soup7

    11 posts

    here are my routes
    $route[‘default_controller’] = “welcome”;
    $route[‘404_override’] = ‘’;
    $route[‘news/create’] = ‘news/create’;
    $route[‘news/(:any)’] = ‘news/view/$1’;
    $route[‘news’] = ‘news’;
    $route[’(:any)’] = ‘pages/view/$1’;
    $route[‘default_controller’] = ‘pages/view’;

    route just means when it sees what’s in the first area, in the [‘blah’] it routes to what comes next, pages/view etc…


    if it’s new/different route, just add it to the bottom will be fine i think

    when they say ‘add code’, look how it changed from (where it was displayed) before, and you’ll see where it changed.

  • #14 / Feb 26, 2013 11:47am

    CodeIgNewbie

    18 posts

    Still 404!

  • #15 / Feb 26, 2013 12:12pm

    soup7

    11 posts

    at what point in the tutorial are you, where you’re getting the 404?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases