web-dev-qa-db-ja.com

Joomla 4でフレームワークとテンプレートのパラメーターを取得する

Joomla 4が間もなく登場し、私はjoomlaの外のphpファイルでjoomlaフレームワークとテンプレートパラメータを取得する方法を知る必要があります。

これはJ3での方法です。

define( '_JEXEC', 1 ); 
define( '_VALID_MOS', 1 ); 
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../..' ));
define( 'DS', DIRECTORY_SEPARATOR ); 
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); 
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); 
$mainframe = JFactory::getApplication('site'); 
$mainframe->initialise(); 

$app = JFactory::getApplication();
$template   = $app->getTemplate(true);
$params     = $template->params;

ありがとうマルコ

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

// Boot the DI container.
$container = \Joomla\CMS\Factory::getContainer();

// Alias the session service key to the web session service.
$container->alias(\Joomla\Session\SessionInterface::class, 'session.web.site');

// Get the application.
$app      = $container->get(\Joomla\CMS\Application\SiteApplication::class);
$template = $app->getTemplate(true);
$params   = $template->params;
1
Sharky