Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
route in module
  • Hi i have having a problem to use routing in modules.my folder structure is
    app/ 
    -----modules
    ---------test
    -----------classes
    -----------config
    -----------------------routes.php
    
    this code below is not working. but works when i put it in app/config/routes.php but not in modules
    <?php
    return array(
        
        'admin/test'=>'test/admin/test/index'
    );
    ?>
    
  • the routes.php file from modules/test/config/ is ONLY executed when there is a module name in the url... like this:
    when you enter page.com/test/smth - as you can see, test is in the URL, so the routes.php from this module is beeing executed.
    but if you enter page.com/admin/test - you will need add those routes in app/config/routes.php
  • I don't want to create new post so I'll just ask here.
    I'm trying to get that work:
    return array(
     '(:segment)/(:segment)/:page/:subid/(:any)' => '$1/$2/$3/$4/$5',
     //content/one/articles/666/15 => 'controller/one/15' with :page=>articles and :subid=>666
    );
    
    Here is more explained sample what I've tried: http://scrp.at/aXO
    None of above worked and I don't know what to try now.
  • '(:segment)/(:segment)/:page/:subid/(:any)' => '$1/$2/$3/$4/$5' Maybe no problem on it. But your comment said: //content/one/articles/666/15 => 'controller/one/15' with :page=>articles and :subid=>666 specified segments 'content/one/articles/666/15'
    $1 : 'content'
    $2 : 'one'
    $3 : 'articles'
    $4 : '666'
    $5 : '15' you wanted 'controller/one/15'(maybe you wanted 'content/one/15'...), so in route.php is: return array('(:segment)/(:segment)/:page/:subid/(:any)' => '$1/$2/$5', and in your controller class, you can get $this->param(':page'), $this->param('subid'). Another way: on route.php : return array('(:segment)/(:segment)/:page/:subid/(:any)' => '$1/$2/$5/$3/$4', and on action definition, write like : function action_functionname(page, subid) { .....} I suggest : return array('(:segment)/(:segment)/:page/:subid/(:segment)' => '$1/$2/$5', because your defined pattern finished with '(:any)', it will match also content/one/articles/666/15/83/98/83/9ck/sdkjf9/fas90j/s9auf........ :D

Howdy, Stranger!

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

In this Discussion