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

查看:53
本文介绍了外部页面中的Joomla菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Joomla模板文件夹之外的页面的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.

有没有可用的方法,例如Wordpress中的"wp_nav_menu",可以帮助我生成菜单.

Are there any method available, such as 'wp_nav_menu' in Wordpress, which would help me to generate the Menu.

推荐答案

您需要遵循两个步骤

首先,使您的外部页面能够运行joomla库.为此,您将需要在外部php页面中包含几行代码

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();

第二,为您想要的菜单创建一个菜单模块,并在自定义位置启用它,例如"xxxx" 然后将以下代码放在您希望放置该菜单的位置

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天全站免登陆