Welcome Guest, Not a member yet? Register   Sign In
Help with Unable to load the requested file
#1

[eluser]getbackwards[/eluser]
Hi, I am trying to make my way through Elliot Haughin's first screencast (http://www.haughin.com/screencasts/).

I've got up to the part where http://localhost/codeig/index.php/ should be dynamically loading the header, content and footer to make up the page. Instead my header appears (In the CI error style) and I get this message:


An Error Was Encountered

Unable to load the requested file: front/modules/pages/loader.php

this is my pages controller

Code:
<?php

    class Pages extends Controller {
    
        function Pages()
        {
            parent::Controller();
            
            $this->table              = 'pages';
            $this->template['module'] = 'pages';
        }
        
        function _run($view)
        {
            $this->templates['view'] = $view;
            
            $this->load->vars($this->template);
            $this->load->view('loader');
        }
        
        function index()
        {
            if ( !$path = $this->uri->segment(1))
            {
                $path = "home";
            }
            
            $this->db->where('path', $path);
            $this->db->where('active', true);
            
            $query = $this->db->get($this->table, 1);
            
            if ($query->num_rows() == 1 )
            {
                $this->template['page'] = $query->row_array();
                $this->_run('single_page');
            }
            else
            {
                die('404! oops');
            }
        }
            
    }

?>

and this is my loader view file:

Code:
<?php
    $this->load->view('front/layout/header');
    
    $this->load->view('front/modules/'.$module.'/'.$view);
    
    $this->load->view('front/layout/footer');
?>

I guess the problem is something to do with $view because if I code my loader file like this:
Code:
<?php
    $this->load->view('front/layout/header');
    
    $this->load->view('front/modules/'.$module.'/single_page.php');
    
    $this->load->view('front/layout/footer');
?>
the header, footer and content load into the page just fine.

What is going wrong? Who did this too me? Any help much appreciated :roll:
#2

[eluser]gtech[/eluser]
you may kick yourself here but in the controller:

$this->templates['view'] = $view;

should be:

$this->template['view'] = $view;
#3

[eluser]getbackwards[/eluser]
You're right, I am kicking myself...

...but it works now Yay!

Thank you so much :-)
#4

[eluser]gtech[/eluser]
no probs Smile.




Theme © iAndrew 2016 - Forum software by © MyBB