Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Uri class - string function
  • I have an idea about the Uri::string() function in the Uri class. This is the default setup.
    // Example URL: http://localhost/controller/method
    echo Uri::string(); // returns controller/method
    

    My idea is to add params to the function to remove segments.
    // Example URL: http://localhost/controller/method/param1?abc=123
    echo Uri::string(); // returns controller/method/param1?abc=123
    echo Uri::string(-1); // returns method/param1?abc=123
    echo Uri::string(0, -1); // returns controller/method?abc=123
    echo Uri::string(-1, -1); // returns method?abc=123
    

    Is this a good idea? If not why not?
  • I don't think this will be something many people need, and if you want it the code isn't that hard to write:
    implode('/', array_slice(Uri::segments(), 1, 3));
    
    Though you did just make me realize the Uri::segments() method is missing, or I'm forgetting where it is...
  • You are right it is not that hard to code. YES, that is what I am missing Uri::segments(); The array does exist though.
    \Request::active()->uri->segments
    

    I'll make an issue about missing segments function.

Howdy, Stranger!

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

In this Discussion