在Joomla3x中,我有以下代码可以从外部脚本加载Joomla核心:
define( 'DS', DIRECTORY_SEPARATOR );
$rootFolder = explode(DS,dirname(__FILE__));
$currentfolderlevel = 3;
array_splice($rootFolder,-$currentfolderlevel);
$base_folder = implode(DS,$rootFolder);
if(!is_dir($base_folder.DS.'libraries'.DS.'joomla')) exit('Error: Could not loaded Joomla.');
define( '_JEXEC', 1 );
define('JPATH_BASE',implode(DS,$rootFolder));
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$application = JFactory::getApplication('site');
$application ->initialise();
$rootUri = explode('/',JURI::root(true));
array_splice($rootUri,-$currentfolderlevel);
$base_uri = JURI::getInstance()->getScheme().'://'. JURI::getInstance()->getHost(). implode('/',$rootUri).'/';但它不再在Joomla 4x上工作了。如何在J4x中加载Joomla核心?
谢谢
发布于 2022-08-13 01:57:19
我找到了这个密码,它有效了。
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(dirname(dirname(dirname(__FILE__))))); // this may change depending on the path file.
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );谢谢
https://stackoverflow.com/questions/73332942
复制相似问题