2

i tried this

    <?php// Render modules inside this article override
$doc = JFactory::getDocument();
$renderer = $doc->loadRenderer("modules");
$raw = array(“style” => "standard");
?>
// Echo the module somewhere in the template
<?php echo $renderer->render("tags-similaires", $raw, null); ?>

where

$renderer = JFactory::getDocument()->loadRenderer('module');
$modules = JModuleHelper::getModuleById('160');
$params = array('style' => 'xhtml');
echo $renderer->render($modules, $params, '');

in this case I have the error message

Call to a member function get() on array

do you have an idea ? Would this work with joomla4?

4
  • 1
    The $params variable probably already exists in the override. Try using a different name...such as $moduleParams = array('style' => 'xhtml');
    – Lodder
    Nov 2 '20 at 10:19
  • Hello it works :-) Since you didn't answer, I can't do +1 !! Just small problem, it doesn't display the module title !? On the other hand joomla 4 coming soon, will it be compatible or will it be necessary to change the code?
    – Hdcms
    Nov 2 '20 at 11:01
  • Added a full answer below
    – Lodder
    Nov 2 '20 at 11:39
  • @Hdcms - could you please take a few moments to accept Lodder's answer on your question, it would be nice from you for the assist and also this question will not come up every months for us by the system... Thank you.
    – Zollie
    Nov 3 '20 at 12:12
3

The $params variable probably already exists in the override. Try using a different name...such as $moduleParams = array('style' => 'xhtml');

Alsi, note that the title most likely isn't appearing because either:

  1. The module title needs to be shown in the module options
  2. The style value being used isn't correct.

The style relates to the mod_Chrome used by the template, which defines styles/layouts for modules.

You're currently using 'style' => 'xhtml', so I assume the xhtml mod_Chrome doesn't exist.

If you're using the default Joomla 4 Cassiopeia template, try:

$moduleParams = array('style' => 'card');

Else you will need to look in templates\YOUR_TEMPLATE\html\layouts\chromes to see what's available.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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