Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Detecting the Action Segment
  • Is there a way to detect the action segment of a URI?
    It can be hard-coded using Uri::segment(n).
    But, what if the app needs to be agnostic to the file system/URI?
  • \Request::active()->action
    
  • // from a controller
    $this->request->action;
    
    // from anywhere else
    \Request::main()->action;
    
    // if you're in a HMVC request and want the action of that request, not the main request
    // $this->request->action works, but you can access it via
    
    \Request::active()->action;
    
    // There is also (from memory, you could look in the request class)
    $this->request->controller;
    $this->request->module;
    // and probably more
    

    hope that helps :)
  • Thanks, Guys.
    All offerings worked as expected.
    Great community.
  • There is also a: $this->request->directory; it returns directory in which controller is. if its> controller/blog.php - it's empty
    if it's in controller/admin/blog.php - it returns admin Good luck

Howdy, Stranger!

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

In this Discussion