簡體   English   中英

如何在joomla組件中呈現自定義HTML模塊

[英]How to render Custom Html module in joomla component

我有一個自定義的HTML模塊,我需要在“組件”視圖中顯示。 如何獲取自定義HTML並將其顯示在組件視圖中。

jimport('joomla.application.module.helper');
// this is where you want to load your module position
$modules = JModuleHelper::getModules('custom');
foreach($modules as $module)
{
echo JModuleHelper::renderModule($module);
}

嘗試上面的代碼..但沒有得到它。 需要解決方案。

當使用getModules() (請注意最后的“ s”),我相信您是在定義位置而不是名稱。 如果您只想渲染1個模塊,則可以使用以下代碼

jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModule( 'custom' , 'Module Title Here' );
echo JModuleHelper::renderModule( $module );

通過使用此功能,您可以在組件中的特定頁面上顯示自定義模塊。

jimport('joomla.application.module.helper');
$module = &JModuleHelper::getModule('mod_custom','Your module name');
echo JModuleHelper::renderModule($module);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM