我正在将我的 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/