Welcome Guest, Not a member yet? Register   Sign In
Weird Routing Problem
#1

[eluser]kirkaracha[/eluser]
I have these routes in config/routes.php:
Code:
$route['people/atoz/:any'] = 'people/atoz/$1';
$route['people/:any/:any'] = 'people/details/$1/$2';

Here's my atoz method in the people controller:
Code:
public function atoz($start_letter = NULL) {
    if(is_null($start_letter)){
        $start_letter = $this->uri->segment(2,0);
    }
    $people = $this->People_model->get_people($start_letter);
    if ($people->num_rows() > 0) {
        $data = array(
            'page_title' => 'Last Names Starting with ' . strtoupper($start_letter),
            'people' => $people->result(),
            'azlist_path' => 'people/azlist',
            'is_admin' => $this->session->userdata('is_admin'),
        );
        $this->template->load('template','people/list',$data);
    } else {
        $data = array(
            'page_title' => 'People',
            'azlist_path' => 'people/azlist',
            'message_text' => 'Sorry, no people whose last name starts with <strong>'.strtoupper($start_letter).'</strong> are listed.'
        );
        $this->template->load('template','shared/display_messages',$data);
    }
} // atoz

When I go to the page in a browser (www.example.com/people/atoz/b/), I get "Sorry, no people whose last name starts with $1 are listed." The $1 is rendered literally instead of the letter b.
#2

[eluser]Dolrich[/eluser]
Try this... Im not sure it would work.

Code:
$route['people/(:any)/(:any)'] = 'people/details/$1/$2';
$route['people/atoz/(:any)'] = 'people/atoz/$1';
#3

[eluser]kirkaracha[/eluser]
OK, adding parenthesis to this route worked:
Code:
$route['people/atoz/(:any)'] = 'people/atoz/$1';

Thanks!

What do the parenthesis do? I don't see anything about them in the documentation, and I have other similar routes that work without them.
#4

[eluser]danmontgomery[/eluser]
http://www.regular-expressions.info/brackets.html




Theme © iAndrew 2016 - Forum software by © MyBB