Welcome Guest, Not a member yet? Register   Sign In
Why will my controller not load?
#1

[eluser]koala kid[/eluser]
Sorry if this is a dumb question but I can't get my controller or view to load. Here's the scenario : (CI 2.0)

Controller > /application/controllers/dashboard.php

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        $this->load->view('inc/head');
        $this->load->view('inc/header');
        $this->load->view('homepage');
        $this->load->view('inc/footer');
    }
}

/* End of file property.php */
/* Location: ./application/controllers/dashboard

URL : http://my-site.dev/index.php/dashboard/

This is exactly the same code I am using for default_controller but no joy! What am I missing?

Thanks.
#2

[eluser]Developer13[/eluser]
Might help if you were to describe what happens when you visit the URL. White / blank page? Error?

I'll assume a white / blank page for now. If you view the source from your browser, does anything show at all? Does it start outputting HTML and then error out somewhere?

If that's the case, errors are most likely being generated but not displayed. I would recommend making sure you have the proper error reporting variables set in your php.ini file.

If all else fails, what happens if you comment out your $this->load->view calls and instead just echo "Hello World"; ?
#3

[eluser]barisv[/eluser]
Yea, if you describle more, we can help you more. Just for test change your index function like below, and check its echo out or not. At least we make sure that the problem is controller doesnt load.

Code:
function index()
{
   echo "its here";
}
#4

[eluser]Phil Sturgeon[/eluser]
If in doubt, move the $config['uri_protocol'] about. Works most of the time.
#5

[eluser]koala kid[/eluser]
Hi all,

thanks for the posts. I've tried all of your comments, I've tried echoing out something and nothing. I've tried changing the URI_PROTOCOL and moving it about and no joy. What I'm seeing is a white page with nothing when I view source. I'm at a complete loss because its all exactly the same as the default controller / view but just the URI is different?????
#6

[eluser]InsiteFX[/eluser]
And in what directory of CI did you place this Controller?
You should create a MY_Controller

Sorry I see now tht you did specify the directory!

InsiteFX
#7

[eluser]Cristian Gilè[/eluser]
Do you autoload a model with the same name of the dashboard controller ?


Cristian Gilè
#8

[eluser]a_bains[/eluser]
Did the welcome controller work when you installed codeigniter?
#9

[eluser]koala kid[/eluser]
Hi all,

yes the default controller was working. I've changed it to one called Site :

Code:
class Site extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {

        $this->load->view('inc/head');
        $this->load->view('inc/header');
        $this->load->view('homepage');
        $this->load->view('inc/footer');
    }
    
    function shout()
    {
        echo "shout";
    }
}

The index function is loading fine using : http://mysite.dev/index.php

However trying to load the shout() function using http://mysite.dev/index.php/shout or http://mysite.dev/index.php/site/shout just falls back to the default controller.

At this point I am not loading any models.

I'm working on my local dev environment, is there any kind of config set up that could be causing this apart from the URI_PROTOCOl as I already tried that.
#10

[eluser]Jaketoolson[/eluser]
what about your .htaccess file contents?

Also, have you enabled error_reporting(E_ALL)




Theme © iAndrew 2016 - Forum software by © MyBB