php - 在外部 PHP 文件中加载 Joomla 3.x 框架和模块

标签 php joomla joomla3.0 phpbb phpbb3

我正在将我的 Joomla 2.5 站点迁移到 Joomla 3.3。

现在我正在努力加载 joomla 框架并在 phpbb-Template 中显示模块。 使用此代码加载 Joomla 框架在 Joomla 2.5 中运行良好:

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。

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

最佳答案

以下内容非常适合我:

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 根目录更改 ../

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

要测试它是否有效,只需使用如下内容:

var_dump($app);

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

关于php - 在外部 PHP 文件中加载 Joomla 3.x 框架和模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23937651/

相关文章:

php - 使用 $this->input->get() 时缺少 @ 符号

php - 如何调用基于滚动条点击的函数?

php - 每次呈现页面时自动将 Google Analytics 代码添加到 HTML 页面

php - 将数据加载到表中而不插入数据

php - 使用 PHP 从 MySQL 中提取列值

php - 一个查询中的多个插入 Joomla

php - 组件安装后 Joomla SQL 查询错误

javascript - PHP生成html文本框计算amt=qty*价格

javascript - 如何在 joomla 3 中添加内联脚本?

php - joomla 2.5 中的保守缓存和渐进缓存有什么区别?