I am working with Joomla 4 and facing an issue where each module I include gets automatically wrapped in a tag with a "custom" class, like so:

<div id="mod-custom153" class="mod-custom custom">
 Module content

<jdoc:include type="modules" name="top" style="raw" />

My Solution:

I am using a module layout called raw.php in my


defined('_JEXEC') or die;

// Get the module
$module = $displayData['module'];

// If the module doesn't have any content, skip (return)
if ($module->content === null || $module->content === '') {

// Output the module content without the surrounding <div>
$pattern = '/<div[^>]*>(.*)<\/div>/s';
preg_match($pattern, $module->content, $matches);
if (!empty($matches)) {
    echo $matches[1];

it seems to work.

But is there a way to automatically prevent Joomla 4 from wrapping modules in tags?

Any guidance would be greatly appreciated.

1 Answer 1


The wrapping is specified in the mod_custom tmpl file, ie in modules/mod_custom/tmpl/default.php.

To remove it just create a site template override for mod_custom, and edit the override default.php file to remove the <div> wrapper.

(Template overrides are described in Layout Overrides in Joomla and Joomla Improved Override Management, for example.)

  • Your approach works. In J3 we could remove the outer div with module chrome ovverrides: function modChrome_raw($module, &$params, &$attribs) { ?> <?php echo $module->content; ?> <?php } Can we no longer do this?
    – iamrobert
    Jun 18, 2023 at 6:40
  • I did a search for a function called modChrome_raw in the Joomla 4 code base and didn't find anything. But I also didn't find anything in Joomla 3.10 either. Jun 19, 2023 at 10:04

Your Answer

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

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