I have a custom Joomla module. In the helper.php class, I need to pass XML field data.

Here is what I have so far.

class modcatbanerHelper {

    // I need to pass here 
    public $selected_cat = $params->get('title');

    public static function moduleCats($data)
       #or pass here...


2 Answers 2


You can pass in your helper's methods the $params as a parameter.

public static function moduleCats($params)
   $title = $params->get('title');

Then when you call the method from your mod_module.php:


This solution helped me to pass xml field data to class in helper.php.

public static function xyz(){
    $module = JModuleHelper::getModule('mod_name');
    $params = new JRegistry();
    $xyz = $params->get('xyz');
    return $xyz;
  1. mod_name -> this is the module name. Please replace this.
  2. $params->get('xyz') -> this is the parameter found in module xml field. Please replace 'xyz'.
  • Thank you for sharing your snippet. Ideally, all answers should include some plain English explanation of how/why it works or reference to documentation or fringe cases where the technique is not well suited. In other words, please try to avoid posting code-only answers because these miss an opportunity to educate and empower future researchers. You may edit your answer at any time. Sep 21, 2021 at 1:38
  • This is not a good solution. It gets parameters of the first instance found in the database. So if you have multiple module instances, it will get the wrong parameters.
    – Sharky
    Sep 21, 2021 at 5:37
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Sep 21, 2021 at 7:59

Your Answer

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

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