简体   繁体   中英

Codeigniter dynamic page overriding controller

I have a dynamic page called link ( from the db ) and I have a controller called link.Is there a way that I can stop them overriding each other?. My routes seem to be over written too.

Example:

In my db I have a url/slug called name but I also have a controller called name . How can I stop them overwriting each other?

What are you trying to achieve? It's better to avoid the name clash whenever possible. You need to work with your routing rules. If I understand you right, you may need to dinamicaly change your routing rules to include all your slug options first. It should look like:

$route['url-slug-1'] = "page/article"
$route['url-slug-2'] = "page/article"
$route['name']       = "page/article" // this should not call your "name" controller

In 'page' controller's 'article' method you can find out the slug value by using URI class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM