1

I know that you can add a controller into the src/Controller/ folder directly, and Joomla automatically recognizes it as a controller class, and you can route to it using either

?controller=controllername
?task=controllername.task

But this doesn't seem to work if the controller class is in a directory, for example: src/Controller/User/ControllerName.php.

How do I use folders?

Edit: The reason for adding folders is because there are many controllers, and having them grouped together is helpful.

0

2 Answers 2

1

One way to do this, in your Controller folder:

class BranchController extends FormController
{
    public function update_localgroup() {
        $file = JPATH_COMPONENT . '/src/Controller/Branch/localgroups.php';
        include $file;
    }
    public function update_region() {
        $file = JPATH_COMPONENT . '/src/Controller/Branch/regions.php';
        include $file;
    }
}

I do this quite a lot to group umpteen sub-controllers.

0

Create a custom implementation of Joomla\CMS\MVC\Factory\MVCFactoryInterface or extend the provided Joomla\CMS\MVC\Factory\MVCFactory class. From your examples there is no clear connection between the URL parameters and class names so you'd have create something like a mapping table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.