本文介绍了外部页面中的 Joomla 菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I am trying to re-create the menu items from main menu in Joomla in a page, which is outside Joomla's template folder.
Are there any method available, such as 'wp_nav_menu' in Wordpress, which would help me to generate the Menu.
解决方案
There are two steps that you will need to follow
First, make your external page capable of running joomla library. To do this you will need to include few lines of code in your external php page
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();
Second, Create a menu module for your desired menu and enable it on a custom position say 'xxxx' and then put the following code where you want the put that menu
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModules('xxxx');
// xxxx is any virtual position, no need to create it anywhere.
echo JModuleHelper::renderModule($module[0]);
这篇关于外部页面中的 Joomla 菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!