首页文章Joomla模板中加载模块的方法

Joomla模板中加载模块的方法

计算机技术 · web 开发2025-12-080次浏览0 个评论

通过模块名称的方式加载模块

php
    /**
     * @description  : method to render the module in component or moduel by moduel name
     * @param         {*} $modName
     * @param         {*} $modTitle
     * @return        {*}
     */
    static public function renderModuelByName($modName, $modTitle)
    {
        jimport('joomla.application.module.helper');
        $module = JModuleHelper::getModule($modName, $modTitle);
        echo JModuleHelper::renderModule($module);
    }

调用方法:

php
<?php TplChahuawuHelper::renderModulesByName('m_header_menu') ?>

通过模块位置的方法加载模块

php
    /**
     * @description  : method to render the module in component or moduel by moduel position
     * @param         {*} $position
     * @return        {*}
     */
    static public function renderModulesByPosition($position)
    {
        jimport('joomla.application.module.helper');
        $modules = JModuleHelper::getModules($position);
        foreach ($modules as $module) {
            echo JModuleHelper::renderModule($module);
        }
    }

调用方法:

php
<?php TplChahuawuHelper::renderModulesByPosition('position') ?>

评论

0

评论加载中…

发表评论

0/2000