Welcome Guest, Not a member yet? Register   Sign In
How to replace underscore with hyphen ?
#1

I know we can declare that in config/routes.php  but is there any other solution since there are a lot of controllers ...
Reply
#2

Yes, you can declare it on every depending route or with a global config in rutes:

$route['translate_uri_dashes'] = true|false;

See here for details (on the bottom): http://www.codeigniter.com/userguide3/ge...uri_dashes

Does this work for you? Otherwise you have to overwrite the CI_Router Class.

Reply
#3

(11-20-2014, 09:40 AM)Rufnex Wrote: Yes, you can declare it on every depending route or with a global config in rutes:

$route['translate_uri_dashes'] = true|false;

See here for details (on the bottom): http://www.codeigniter.com/userguide3/ge...uri_dashes

Does this work for you? Otherwise you have to overwrite the CI_Router Class.

That's a CI3 feature.
Reply
#4

@Narf: your right .. i dont looked at the board title.

Ok again, there are some usefull examples arround the web. The goal is to overwrite the routing class with an own logic like

Create a file in 'application/core' and name it to 'MY_Router.php'

PHP Code:
class MY_Router extends CI_Router
{
    function 
_set_request($segments = array()) {
        
parent::_set_request(str_replace('-''_'$segments));
    }


A more complex solution are described here http://upshots.org/php/codeigniter-hyphenated-urls

Reply




Theme © iAndrew 2016 - Forum software by © MyBB