The helper.php file contains that helper class that is used to retrieve the data to be displayed in the module output. Most modules will have at least one helper but it is possible to have a module with more or none.

Directory Structure & Files

The directory structure used for MVC oriented modules includes the helper.php file in the top directory for that module. While there is no rule stating that we must name our helper class as we have, but it is helpful to do this so that it is easily identifiable and locateable.



In our mod_helloworld example, the helper class will have one method: getItems(). This method will return the items we retrieved from the database.

Here is the code for the mod_helloworld helper.php file:

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

class modHelloWorldHelper
     * Retrieves the hello message
     * @param array $params An object containing the module parameters
     * @access public
    public function getItems( $userCount )
        return 'Hello, World!';

More advanced modules might include multiple database requests or other functionality in the helper class method.

Last modified: