Welcome Guest, Not a member yet? Register   Sign In
Can't extend CI_Controller
#7

[eluser]Lukas1[/eluser]
Hello, thanks for answer. I don't use CI Reactor, I use the stable version of CI.

I am not sure, you understand my problem well, after reading your answer. It seems to me, you think, that I am not able to create a Controller. This is not the case, I don't have any problems with that. I want to extend the core CI_Controller however, and let my controllers extend not the CI_Controller, but my extended Controller.

So for example, let's say, I want to have a Test_controller. If I would want to just create a controller I can do this
Code:
public class Test_controller extends CI_Controller {
    public function index() {
      //do something
    }
  }

This approach works for me. And this is, where URL is involved.

However I want for example to have every of my controller a function that will return some concrete value.. I don't know, for example HTML header.

So I want to do this:
in application/core/my_controller.php
Code:
public class MY_Controller extends CI_Controller {
    protected function get_html_header() {
      return '<head><title>Title of this page</title><'head>';
    }
in application/controller/test_controller.php
Code:
public class Test_controller extends MY_Controller {
    public function index() {
      $htmlHeader = $this->get_html_header();
      //do something
    }
  }

When I run this on my computer with Wamp Server, it works just as documented. However after uploading my CI project with this code, I get error:
Fatal error: Class ‘MY_Controller’ not found in [PATH]/application/controller/test_controller.php

So URL is correct, it's not a problem of wrong URL, it has absolutely nothing to do with it.

For now I have to manualy include my_controller.php to every of my controllers, if I want to have my project run on the server. I don't know why is this the case, why including application/core/my_controller.php fails...


Messages In This Thread
Can't extend CI_Controller - by El Forum - 04-04-2011, 10:17 AM
Can't extend CI_Controller - by El Forum - 04-04-2011, 10:21 AM
Can't extend CI_Controller - by El Forum - 04-04-2011, 10:23 AM
Can't extend CI_Controller - by El Forum - 04-04-2011, 01:37 PM
Can't extend CI_Controller - by El Forum - 04-04-2011, 02:52 PM
Can't extend CI_Controller - by El Forum - 04-04-2011, 03:47 PM
Can't extend CI_Controller - by El Forum - 04-05-2011, 12:59 AM
Can't extend CI_Controller - by El Forum - 04-05-2011, 08:35 AM
Can't extend CI_Controller - by El Forum - 04-05-2011, 09:22 AM
Can't extend CI_Controller - by El Forum - 04-05-2011, 11:15 AM
Can't extend CI_Controller - by El Forum - 04-05-2011, 12:22 PM
Can't extend CI_Controller - by El Forum - 04-10-2011, 05:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB