簡體   English   中英

在外部PHP文件中加載Joomla 3.x框架和模塊

[英]Load Joomla 3.x Framework and Modules in external PHP file

我正在將我的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);

如果您看到顯示的數據,那么您已成功導入框架

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM