Hi. I have URI Language Identifier on my website I did it according to directions on codeigniter WIKI. It works fine. But How Can I get name of controller because $this->uri->segment(2) = id and $this->uri->segment(1) = name of the metod.

This is my routes.php

$route['default_controller'] = "page";
$route['404_override'] = '';
$route['(\w{2})/(.*)'] = '$2';
$route['(\w{2})'] = $route['default_controller']; 

Thanks for reply.

Recommended Answers

All 2 Replies

what is $this->uri->segment(0) ?

From where do you want to get controller name ? If you want to get from view, you can use $this->uri->segment(1). You can use CI default functions get_instance() to get the current object and then use get_class($CI) to get the object name as string. Example below:

$CI =& get_instance();
echo get_class($CI); // return the current object (i.e, controller name) as string
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.