• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieving the default controller config item


The problem is: I'd need to retrieve
from a post-controller-constructor hook.

There's the raw way, which consists in copying the Router library code directly inside the hook:
// Load the routes.php file.
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
The point is: this file has already been loaded and the class has already been created (in the system/codeigniter/CodeIgniter.php file, under the name $RTR).

But once the controller is loaded, I can't find it anymore :-S

Any idea?

Gosh I posted that too fast..

A simple:
$ci =& get_instance();
is what I was looking for. I found it using:
Problem solved.

PS: it's incredibly useful to var_dump() the main controller from time to time to remember all the things it carries with it along the code execution ;-).

Hi NemetraL,

Have you tried?

echo "<br /><pre>";
  echo "</pre>";
echo "<br /><pre>";
  echo "</pre>";

Yes the problem is solved now.

I had to go through the var_dump(), which default layout is less readable than the print_r() by the way ;-).

I wonder if there's a way to do this using CI 2.02 ?

I tried your method and it returns an error.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.