Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a controller's URL from a view in Codeigniter?

Let say I am at my View loaded by my controller named Book.

Is there any way for me to get my controller’s URL at View instead of manually typing:

echo base_url('book');  
like image 784
user826224 Avatar asked Nov 22 '11 16:11

user826224


People also ask

Where is base URL in CodeIgniter?

The base URL of the site can be configured in application/config/config. php file. It is URL to your CodeIgniter root.

How do I find my CI controller name?

The fetch_class() and fetch_method() method of Router class can be used to read the class and method property in CodeIgniter. Use fetch_class() method to get the name of the controller or class in CodeIgniter. Use fetch_method() method to get the name of the method or function in CodeIgniter.


1 Answers

To return the current controller, you can use.

$this->router->fetch_class();

Equally, if you wanted to return the current method, then you could use:

$this->router->fetch_method();
like image 168
MY_Mark Avatar answered Oct 22 '22 22:10

MY_Mark