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.

Newbie needs help with application folder path

December 03, 2012 12:12am

Subscribe [1]
  • #1 / Dec 03, 2012 12:12am

    eldorado2768

    2 posts

    Hello:

    I am going thru the beginning tutorial and I created the controller for pages:

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

    Problem is I keep getting the 404 error page when I navigate to pages/view. I checked my index.php file in my public_html folder and the application path is set correctly. If I comment out the show_404(); the pages load fine. If I change the path in the if (! file_exists statement to be the full path from the server it works fine. So something is going on with the setting for the default path to the application but I don’t know what. Anyone have any ideas?

  • #2 / Dec 03, 2012 3:09pm

    eldorado2768

    2 posts

    Update to my post:

    Someone in stackoverflow had the exact same problem as me. When I updated the if statement to the following, the problem went away:

    if(!file_exists( APPPATH . ‘views/pages/’.$page.’.php’))

    So APPPATH was needed.

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

ExpressionEngine News!

#eecms, #events, #releases