外部页面中的 Joomla 菜单 [英] Joomla Menu In External Page

查看:18
本文介绍了外部页面中的 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 菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆