Uri routing

edited March 2011 in Modules
I've just created the news module from Creating Pages tutorial, so it works on example http://testsite.com/news and http://testsite.com/news/slug

What I have to do if I want to news module also available on the frontend with http://testsite.com/something/this-is-news and http://testsite.com/something/this-is-news/slug urls? I try to modify the url in CI's route.php, but

$route['something/this-is-news'] = 'news'; $route['something/this-is-news/(:any)'] = 'news/$1';
not works. It can be possible that I don't understand the basics of FUEL's uri routing, so any idea can be helpful :)

Comments

  • edited 2:40PM
    In this case, FUEL uses view files to see if a page exist and in this case there are no view files that match. The key is to map a 'view' variable to the URI location. For the news example, it says to insert a news variables file to map the view file to the URI location. You will also need to do the same with the above URI location in a 'something' variables file:

    (fuel/application/views/_variables/something.php)
    $pages['something/this-is-news/:any'] = array('view' => 'showcase/project');

    Make sense?
  • edited 2:40PM
    Yes, it makes and that's what I've searched for! Thanks!
  • edited 2:40PM
    How do you make this case-insensitive?

    ie. this doesn't work:
    $pages['something/Something/this-is-news/:any/This-Is-News/:any'] = array('view' => 'showcase/project');

    any easy idea?

    Thanks! :)
  • edited 2:40PM
    I think to make that case insensitive you would need to make a change in the core code to the regular expression that is doing the matching. On line 134 of the fuel/modules/fuel/libraries/Fuel_pagevars.php file, there is a line of the following:
    if (preg_match('#^'.$key.'$#', $location))
    It may be worth trying to add the case insensitive flag (i) like so:
    if (preg_match('#^'.$key.'$#i', $location))
Sign In or Register to comment.