外部页面中的 Joomla 菜单

Joomla Menu In External Page(外部页面中的 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.

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 菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)