1

Joomla 4 is coming soon and i need to know how to get the joomla framework and template params in php files outside of joomla.

This is the way in 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;

Thanks Marco

1
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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.