Unlike components, which potentially can have multiple controllers, modules do not have a controller class. As such, the module directory structure doesn't include a /controllers subdirectory or controller.php. Instead, the setting of parameters, inclusion of any necessary files, and the instantiation of the module's view are done within the mod_{ModuleName}.php file.

Directory Structure & Files

The controller is stored in the same directory as the module file itself and must be named the same (the file extension being the obvious difference).



Most modules will perform three tasks in the following order:

  • Include the helper.php file which contains the class to be used to collect any necessary data
  • Invoke the appropriate helper class method to retrieve any data that needs to be available to the view
  • Include the template to display the output

Here are the contents of mod_listnames.php:

// No direct access
defined('_JEXEC') or die('Restricted access');

// Include the helper file
require_once(__DIR__ . DS . 'helper.php');

// Get the items to display from the helper
$mod = new modListNames($params, $module);

Last modified:

  • Copyright © 2022 Hubzero
  • Powered by Hubzero®