Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
does it support url automatic create base on router or not?
  • i check documents there is no talking about this.
    i mean
    'post'=>'post/index', 
     'post/(:any)'      => 'post/view/$1',
    
    if two routers than how to create link, also when this routers not exists also work fine.
    i know
    echo Router::get(); \Uri::create() is for controller action
    
    how can i do ?
    thank you
  • if i solve this question,our cms will release soon.
    automatic create link is very importent
  • For Router::get() to work you need a named route, as documented here: http://docs.fuelphp.com/general/routing.html#/named_routes And Router::get() needs a parameter with the name of the route to fetch, so your code is pretty pointless, it doesn't do anything. Also note that in v1.2, named routes are only supported for plain routes and routes with named parameters. Regexes (both coded manually and using :any/:segment shortcuts) are not supported. Support for this has been introduced in v1.3-dev.
  • is that mean i must add router in router.php then it is work,if not ,router::get return nothing.
    i check it and if router not exists it return nothing.
    thanks
  • i am tring
    'post'=>array('post/index','name'=>'post'), 
    
     'post/(:any)'      => array('post/view/$1','name'=>'post_view'),//this one how to create link?
    

    and use
    <?php echo Router::get('post');?><br>
     
    <?php echo Router::get('post_view','jj');?><br> 
    
    it is show
    http://t.com/post.html
    [url=http://t.com/post/(:any]http://t.com/post/(:any[/url]).html
    
    but when i visite http://t.com/post.html it is show 404 if http://t.com/post/index.html it work fine.
    so http://t.com/post.html is bad.
  • config.php
    url_suffix=''
    
    why link has
    .html
    

    now i use
    'post/:title'      => array('post/view','name'=>'post_view'),
    
    <?php echo Router::get('post_view',array('title'=>'test'));?><br> 
    
    this is work. is there any comm router ?
    like YII http://www.yiiframework.com/doc/guide/1.1/en/topics.url
  • why
    'post'=>array('post/index','name'=>'post'),
    
    when i visit post.html not work.
    but post/index.html work fine?
    return array(
     '_root_'  => 'home/index',  // The default route
     '_404_'   => 'welcome/404',    // The main 404 route
     
     
     'admins'=>'admin/home/index',
      
     
     '(:any)!'      => 'home/user/$1', 
     
     'post_view/:title'      => array('post/view','name'=>'post_view'),
     'post'=>array('post/index','name'=>'post'),
    );
    
    'post-:title'      =>   array('post/view','name'=>'post_view'),
    
    not support
  • Rules are processed in the order in which they are defined. Your :any rule will capture /post before it gets to the later rules... v1.2 doesn't support regexes, regex aliases. It does support normal routes and routes with named parameters. For the last one you'll have to provide the replacement:
    // for a route: 'post-:title' => array('post/view','name'=>'post_view'), use
    
    echo Router::get('post_view', array('title','this-is-the-title-of-the-post');
    
    // will echo }http://yoursite/post-this-is-the-title-of-the-post";
    
  • i find post.html router not work, but post/index.html work fine. how can i set that?
    i use
    <?php echo Router::get('post_view',array('title'=>'test'));?><br>
    
    'post-:title'      =>   array('post/view','name'=>'post_view'),
    
    not work..
    it is out post-test.html but when i visit post-test.html ,show 404
    please check
  • Just tried that here, and it works fine. Note that as I said, reverse routing with regexes only works as of 1.3/develop, it is not available in 1.2.
  • ok.so if i want touse,i should upgrade fuelphp 1.2 to 1.3?
    or just copy router.php from 1.3?

Howdy, Stranger!

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

In this Discussion