在外部页面上显示 Joomla 菜单
Showing Joomla menu on external page
您好,我想在我的外部页面上显示 joomla 菜单,这是我在外部 php 文件中的代码,有没有其他方法可以做到这一点,在此先感谢您的帮助。
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__).'/../' ); // should point to joomla root
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModules('xxxx');
echo JModuleHelper::renderModule($module[0]);
如何执行此操作的示例显示在 offline.php 和 error.php 模板中。
例如
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
//all the code to start your html
<div class="navigation">
<?php // Display position-1 modules ?>
<?php echo $doc->getBuffer('modules', 'position-1', array('style' => 'none')); ?>
</div>
// all the code to end your html
来自原星
您好,我想在我的外部页面上显示 joomla 菜单,这是我在外部 php 文件中的代码,有没有其他方法可以做到这一点,在此先感谢您的帮助。
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__).'/../' ); // should point to joomla root
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModules('xxxx');
echo JModuleHelper::renderModule($module[0]);
如何执行此操作的示例显示在 offline.php 和 error.php 模板中。
例如
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
//all the code to start your html
<div class="navigation">
<?php // Display position-1 modules ?>
<?php echo $doc->getBuffer('modules', 'position-1', array('style' => 'none')); ?>
</div>
// all the code to end your html
来自原星