I think you're confusing the purpose of your main / master controller (controller.php
) and subcontrollers (everything in the /controllers
folder). For more on this, see the docs.
The main controller is typically used to do what you mention in your comment (render a view based on the view
parameter, usually specified in the URL). In controller.php
, the function that does this is called display()
. So the following URL:
http://example.com/index.php?option=com_mycomponent&view=test
Will result in calling the display()
function in controller.php
and loads the view test
in /views/test
.
Subcontrollers, in the controllers
folder, are generally used for CRUD tasks, but can be called easily by using a task
URL parameter. For example:
http://example.com/index.php?option=com_mycomponent&task=test.process
Will result in calling the process()
function in /controllers/test.php
- notice the task
parameter is <controllerName>.<functionName>
You'll see this used a lot to do actions that don't need a view, e.g in com_content
to publish / checkin / checkout / delete articles (where the task
is article.publish
etc.,which means the controller at controllers/article.php
and the function publish()
, and instead of a dedicated view the controller just redirects back to the list view).
For more information on how all the Joomla MVC parts fit together, see this wiki article.
Good luck!