![]() |
get url from a controller and method - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: get url from a controller and method (/showthread.php?tid=64948) |
get url from a controller and method - jonathanq - 04-13-2016 Hello, Is posible get url from a controller and method Something like this: file routes.php $route['blog/from/controller/home'] = 'ControllerName/Home'; And anywhere controller $url = $this->router->get_url('ControllerName','Home'); echo $url; //exit must be "blog/from/controller/home" RE: get url from a controller and method - Wouter60 - 04-13-2016 Did you try this: PHP Code: $this->load->helper('url'); // if you need this often, autoload the helper in config/autoload.php RE: get url from a controller and method - jonathanq - 04-14-2016 (04-13-2016, 12:33 PM)Wouter60 Wrote: Did you try this: thanks, but i want know a url from another Controller not current url, you know? RE: get url from a controller and method - Wouter60 - 04-14-2016 Maybe this will help you: PHP Code: if (file_exists(APPPATH.'config/routes.php')) You can determine which controller/method is assigned to which route: PHP Code: $find = 'ControllerName/Home'; If you're working with different config.php files for different environments, the code will need a little more tweaking. Take a look at the system/core/Router.php file. RE: get url from a controller and method - Tpojka - 04-16-2016 Check URI library. Maybe PHP Code: $this->uri->uri_string(); or PHP Code: $this->uri->ruri_string(); could work for you. RE: get url from a controller and method - aajiwani - 04-20-2016 This was the exact problem that I was facing. I called it named routes. I have created a infrastructure for it to work, may be you can check and see if it is the right solution or not. Here is the link : https://github.com/aajiwani/LaravelRoutingForCodeIgniter |