mehulmpt
mehulmpt

Reputation: 16547

Redirecting controller control to sub-controller

I'm using FuelPHP for my website. Currently, I've the following structure:

-folder1
  -FILEHERE.php
-folder2
...
-fuel
  -app
    -classes
      -controller
        -learn.php
        -folder1.php
-public

I've created a controller in fuel->classes->controller with the name learn.php. Now what I want is this: If the person visits http://example.com/learn -> this controller fires up (learn.php). I want to add a sub-controller and throw control to that whenever there is a next directory request. i.e.: http://example.com/learn/folder1 should throw control to folder1.php in fuel->classes->controller.

How do I do this? I've checked the methods action_* but they don't look flexible. Also, once the user visits something like: http://example.com/learn/folder1/FILEHERE It should load the content file from folder1->FILEHERE.php (see the directory layout above)

Thank you for your help!

Upvotes: 1

Views: 73

Answers (1)

Emlyn
Emlyn

Reputation: 862

You can easily do this using FuelPHP's routing functionality. Which is documented here.

Your basic route config for the folder1 controller might look something like this:

'learn/folder1'   => 'folder1/index',

The documentation outlines more complex examples as well if needed.

Upvotes: 0

Related Questions