Welcome Guest, Not a member yet? Register   Sign In
Unlikely question...
#1

[eluser]Unknown[/eluser]
I am running codeigniter 2 with Smarty 3.

I am have my site menu running from a library which is called from the smarty file with the header in it.

I want to use the same library function for my admin area so that I can use the same header file. The admin uses a different controller though.

In CI is there a way of working out which controller I have run the page in?

So for example in my library I could put something like:

if(ci_controller == 'admin'){
show admin menu
}else{
show main menu
}

thanks... alternatively I guess this can be worked out with some php...
#2

[eluser]AoiKage[/eluser]
If you have something like "www.yoursite.com/admin" or "www.yoursite.com/index.php/admin" in the url you can just grab the controller name using the URI Class:

Code:
if ($this->uri->segment(1) == 'admin')
{
    // load admin menu
}
else
{
    // load main menu
}

The URI class is ALWAYS autoloaded so you don't have to load anything to make this work Smile

I hope this solved your problem Wink
#3

[eluser]InsiteFX[/eluser]
Code:
private $CI;
private $controller;
private $method;

$this->controller = $this->CI->router->fetch_class();
$this->method     = $this->CI->router->fetch_method();

InsiteFX
#4

[eluser]Unknown[/eluser]
Thanks AoiKage, your suggestion worked perfectly.




Theme © iAndrew 2016 - Forum software by © MyBB