1

I have this route in Codeingniter

$route['([en|fr|es|it]+)/(.+)'] = 'My_Controller/index/$1/$2';

where first argument is a lang id and second is an unique iD. The ID has slashes in its format like:

item/34/public    
something/else
name/for/this/can/be/12345

Number of slashes in ID can be from 0 to (nobodyknows) so actually I´m getting the id in My-Controller with this hack :

public function index($lang,$id)
{
    $hack_id = $this->uri->segment(3);

    if ($this->uri->segment(4)) {
         $hack_id .= "/".$this->uri->segment(4);
    }

    if ($this->uri->segment(5)) {
        $hack_id .= "/".$this->uri->segment(5);
    }

    /*...and so go on if clauses, repeating and concatenating ...*/
    /* and finally passing the hack_id data to view */
}

It works, but I think it's a weird solution (I'm not really passing any id) and must be a way to do it better, a smarter solution (maybe in routes?).

Any help or clue are welcome...

vicmontol
  • 139
  • 6
  • Can you use something from [this answer](http://stackoverflow.com/questions/32831107/how-to-select-all-after-uri-segment-2-in-codeigniter/32832266#32832266)? – Tpojka Oct 05 '15 at 17:13

0 Answers0