• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URL routing

#1
[eluser]Richko[/eluser]
Hello maybe anyone have idea how to make that type of url routing?
if i call www.web.com/article_name_or_controller/ i want that my app first check if exists entry in db by that article name and shows it from page controller, if it not exist then makes the other controller work.

Sorry for bad englishSmile

#2
[eluser]gon[/eluser]
I think this can't be done 'cause CI will load the controller if it exists.

You can however put a _remap call into the main controller, that will receive all calls, with the article name passed as an argument. So you check if the article exists in the database. But as I just noted, I think this won't work if a controller exists with the same name.

Another way can be using hooks. Before the controller is loaded, you can "intercept" the arguments.

But I wouldn't do that unless it is absolutely neccesary.

Why don't have a controller named "article":

host.com/article/name

this would be even better for users to remember the URLs.

cheers.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.