CodeIgniter Forums
Can Not extends Core Controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Can Not extends Core Controller (/showthread.php?tid=52598)

Pages: 1 2


Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]qpixo[/eluser]
I'm trying to extend core Controller but it doesn't work after I upgraded CI to version 2.1.1
I can't see the display TEST log in, it's a blank page

Does anyone know how to fix that issue?

in direction application/core:
Code:
class MY_Controller extends CI_Controller {

// Defined a global user to all View
protected $user;

// Constructor
public function __construct() {
  
  parent::__construct();
  
  
  // Check if is member
  if($this->ion_auth->is_group('members')) {
   $data->user = $this->ion_auth->user()->row();
   $this->user = $data->user;
  
   // Load user to every Views
   $this->load->vars($data);
  } else {
   redirect('/');
  }
}
}

Then I extend this base controller in application/controllers/members

Code:
class Dashboard extends MY_Controller {

// Constructor of Dashboard
public function __construct() {
  
  parent::__construct();
  
  echo "TEST log in!!";
}




Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]Samus[/eluser]
[quote author="qpixo" date="1340042305"]
Code:
class Dashboard extends MY_Controller {

// Constructor of Dashboard
public function __construct() {
  
  parent::__construct();
  
  echo "TEST log in!!";
}

[/quote]
Obviously, you're technically not echoing it in any 'page'.

try..

Code:
class Dashboard extends MY_Controller {

// Constructor of Dashboard
public function __construct() {
  
  parent::__construct();
  
function index() {
  echo "TEST log in!!";
}
}



Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]qpixo[/eluser]
[quote author="Samus" date="1340043947"][quote author="qpixo" date="1340042305"]
Code:
class Dashboard extends MY_Controller {

// Constructor of Dashboard
public function __construct() {
  
  parent::__construct();
  
  echo "TEST log in!!";
}

[/quote]
Obviously, you're technically not echoing it in any 'page'.

try..

Code:
class Dashboard extends MY_Controller {

// Constructor of Dashboard
public function __construct() {
  
  parent::__construct();
  
function index() {
  echo "TEST log in!!";
}
}
[/quote]

I know it's just a lazy way to do it but yours still doesn't work...


Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]Samus[/eluser]
sorry.
Code:
class Dashboard extends MY_Controller {

// Constructor of Dashboard
public function __construct() {
  
  parent::__construct();
  }
function index() {
  echo "TEST log in!!";
}


how about that?


Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]TWP Marketing[/eluser]
Did you set the correct default controller in config/routes.php?


Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]Matalina[/eluser]
Are you sure you are logged in?



Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]qpixo[/eluser]
[quote author="TWP Marketing" date="1340047433"]Did you set the correct default controller in config/routes.php?[/quote]

Yes I did


Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]qpixo[/eluser]
[quote author="Matalina" date="1340051636"]Are you sure you are logged in?
[/quote]

When I test and use CI_Controller I can see the page but not with my custom controller. What the heck? Is it a bug?


Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]Matalina[/eluser]
The CI control doesn't redirect you. Your Custom controller does. Make sure everything in your construct is doing it's job correctly. Your extension looks correct it's the code in your construct that isn't doing it's job correctly.


Can Not extends Core Controller - El Forum - 06-18-2012

[eluser]Matalina[/eluser]
it should be in group not is group

Code:
$this->ion_auth->in_group('members')