简体   繁体   English

在Joomla中使用JModuleHelper :: getModule加载自定义html模块

[英]Load custom html module with JModuleHelper::getModule in Joomla

I'm using the following code to render a joomla! 我正在使用以下代码渲染joomla! module: 模块:

        jimport('joomla.application.module.helper');
        $module = JModuleHelper::getModule('AddToCartReplacementBtn');
        echo JModuleHelper::renderModule($module);

However it doesn't seem to work in my specific case 但是在我的特定情况下它似乎不起作用

I'm loading a custom HTML module with the name AddToCartReplacementBtn . 我正在加载名为AddToCartReplacementBtn的自定义HTML模块。 Its position is also AddToCartReplacementBtn 它的位置也是AddToCartReplacementBtn

The documentation says that I can load a module by its real name or the folder. 该文档说,我可以按模块的真实名称或文件夹加载模块。

Is there any other way of loading a module by its real name? 还有其他方法可以按其真实名称加载模块吗?

$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$module = JModuleHelper::getModule('mod_custom','AddToCartReplacementBtn');
echo $renderer->render($module);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM