Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing Help
  • Hello guys, Say I want to have this setup:
    site.com/en/this-is-some-category/this-is-some-post
    site.com/en/this-is-some-category/pag/1
    site.com/en/this-is-some-category and all of the above without the /en/
    like: site.com/this-is-some-category

    I'm still learning how Routing works, so.. Normally, in my own 'cms' I have made for my clients, I don't have this friendly url's
    Or i mod_rewrite, each specification directly.
    'category/:cat_name' => 'category/$1',
    Would this example, work for site.com/category/name-of-category ?
    But what about all of the rest? I'm sorry I didn't find a clear answer to this anywhere else. Thanks
  • What I've done is alter the routes.php file and add a prefixed variable to each route. You can set this variable in the APP bootstrap, but if you pre-load a library to handle setting this variable, it won't work because the routes.php file gets called first. I've had no luck making changes to the routes config at run-time. Example (routes.php): $user_language = Cookie::get('language', ''); return array(
    $user_language.'this-is-some-category/this-is-some-post' => 'this-is-some-category/this-is-some-post'
    );
  • can you tell me how look the link you use to call '$user_language.'this-is-some-category/this-is-some-post', so fuel doesn't think $user_language is the controller?
    thank you
  • Hello. Maybe some thing like that: http://pastie.org/2625598 I do not sure it is right solution or not.
    And do not forget to use validation. If you want to use prefix 'EN' - I think it will be better to use it in cookies. Sure also you can use it in routing, but little bit need to think how to make controller.
  • New idea, if you want to use in URL - prefix EN - you can make two controllers. class Controller_Category extends Controller_Common
    {
    public function before()
    {
    parent::before();
    }
    //here actions index ent etc.
    } class Controller_Common extends Controller (_Template)
    {
    public function before()
    {
    //And here to check sifix.
    if isset EN show EN Lang
    if isset FR show FR Lang
    etc. $uri_string = explode('/', Uri::string());
    if ($uri_string[0] == 'EN') or use switch case. I do not know. :)
    }
    }

Howdy, Stranger!

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

In this Discussion