Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing scenario help
  • Hello, I am not quite sure how to set up routing for one of my pages. I have following scenario. It's a news page and I would like to have routing like this: http://www.mypage.com -> follows default _root_ route to cover.php controller
    http://www.mypage.com/cover -> same as above routes to conver.php controller This above is basic stuff and is already set. What I would like now is to have a route when a particular article is opened to route into articles.php controller. For example: http://www.mypage.com/this_is_some_article_x -> articles.php with "this_is_some_article_x" as parameter to fetch the article out
    http://www.mypage.com/this_is_some_article_y -> articles.php ... How should I approach this? One way is to have a route set like this:
    return array(
     '_root_'  => 'cover',  // The default route
     'article/(:any)'  => 'articles/show/$1',
    );
    
    but this would then route to something like this (with additional '/articles/' in url):
    http://www.mypage.com/articles/this_is_some_article_x
  • Thanks with your help I got the right results.
  • maybe... return array(
    '_root' => 'cover', // This route into Controller_Cover class, action_index()
    'cover' => 'cover', '(:segment)' => 'articles/show/$1', // If you want get all segement, like domain/articlex/articley/articlez......, yes, you can use (:any), but you intend to get one segment, so use (:segment)
    );

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion