• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Routing Question

#1
Thumbs Up 
Glad to hear an update from CI 2.x Series. And wanna ask about routing. First, i dunno which thread exactly to ask this question, so sorry if i got wrong thread here. As i'm using CI 2.2.1 and this is a thread that newest from it's series so i ask here.

Second, sorry for my bad english. I'm from indonesia and still understanding to develop using this framework.

And here's my question, i'm playing with route. Like this below :

Code:
$route['(:any)'] = 'smpht/index/page/$1';

it explained that any first segment will routed to smpht controller, index method, and page as first param. How i can tell the CI to search controller first, than if there's no controller it will routed. like example below :

Code:
http://localhost/lorem

first it will find 'lorem' controller, when 'lorem' controller doesn't exist it will routed to :

Code:
http://localhost/smpht/index/page/lorem

if there's anyone knows the answer, i'm totally happy to hear the solution. thanks before.
Reply

#2
Hello,
Have you tried to use _remap function?
Just check the first segment of the url then you can make a condition where you want to pass them.

public function _remap(){
$segment_1 = $this->uri->segment(1);
$segment_2 = $this->uri->segment(2);

switch ($segment_1) {
case 'lorem':
//condition here..
break;
}
}

hope it help Smile
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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