在外部PHP文件中加载Joomla 3.x框架和模块 [英] Load Joomla 3.x Framework and Modules in external PHP file

查看:173
本文介绍了在外部PHP文件中加载Joomla 3.x框架和模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的Joomla 2.5网站迁移到Joomla 3.3.

I am migrating my Joomla 2.5 site to Joomla 3.3.

现在,我正在努力加载joomla框架并在phpbb-Template中显示模块. 使用以下代码在Joomla 2.5中可以很好地加载Joomla框架:

Now I'm struggling with loading the joomla framework and displaying a module in a phpbb-Template. Loading the Joomla framework worked fine in Joomla 2.5 with this code:

define( '_JEXEC', 1 );
define('JPATH_BASE', '/var/customers/webs/tf2swiss/joomlasite');
define( 'DS', DIRECTORY_SEPARATOR );
require_once('../configuration.php');
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );
require( JPATH_LIBRARIES. '/import.php');
// Joomla! library imports
jimport( 'joomla.environment.uri' );
jimport( 'joomla.user.user');
jimport('joomla.application.module.helper');

/* Create the Application */
$mainframe =& JFactory::getApplication('site');
jimport('joomla.plugin.helper');

但是我现在不在Joomla 3.x中工作.页面会在此代码所在的位置停止加载. 在安全性"选项中启用了在phpbb模板文件中使用PHP.

But I doesn't work in Joomla 3.x now. The page stopps loading where this code is. Using PHP in phpbb template files is enabled in the Security options.

有人知道如何在外部文件中加载joomla 3.x框架吗?

Does anyone know how to load the joomla 3.x framework in external files?

推荐答案

以下内容非常适合我:

define('_JEXEC', 1);
define('JPATH_BASE', '../');
require_once JPATH_BASE . 'includes/defines.php';
require_once JPATH_BASE . 'includes/framework.php';

// Create the Application
$app = JFactory::getApplication('site');

尝试将当前需要的这一行更改为相对路径,如上所示.您可能要根据相对于外部文件的Joomla根目录来更改../.

Try changing this line which you currently have to a relative path as shown above. You may been to change ../ according to where you have your Joomla root in relation to your external file.

define('JPATH_BASE', '/var/customers/webs/tf2swiss/joomlasite');

要测试其是否正常运行,只需使用如下代码:

To test if it's working, simply use something like this:

var_dump($app);

如果看到显示的数据,则说明您已经成功导入了框架

If you see data being shown, then your have successfully imported the framework

这篇关于在外部PHP文件中加载Joomla 3.x框架和模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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