Arnor Baldvinsson
Hi,
I have a large, proprietary component that we are moving up to Joomla 4. We use Modals in a few places. I have Modals installed and there were no issues with that (I did not migrate Modals along with Joomla, accidentally removed it as I was doing cleanup in 3.10.11 prior to migrating!) I'm NEW to J4 but I've been messing with the innards of J3 for the past 6 years, so not exactly a novice, but not an expert either.
We use Modals to open pages on the site (not articles, just .PHP files that contain HTML and generate HTML) We had no issues with this in Joomla 3, but I'm not able to get past just setting up the page and the required Joomla classes.
It needs the application reference. So I use:
$app = \Joomla\CMS\Factory::getApplication();
$document = $app->getDocument();
This works in other places, but here all I get is an error "Failed to start application" I have cut this file down to:
<?php
define('_JEXEC', 1);
$ds = DIRECTORY_SEPARATOR;
define('JPATH_BASE', realpath(dirname(__FILE__) . '/../../../..'));
$def = JPATH_BASE . $ds . 'includes' . $ds . 'defines.php';
$fw = JPATH_BASE . $ds . 'includes' . $ds . 'framework.php';
echo "<br>path: " . JPATH_BASE;
echo "<br>def: " . $def;
echo "<br>fq: " . $fw;
require_once $def;
require_once $fw;
$app = \Joomla\CMS\Factory::getApplication();
$document = $app->getDocument();
$userID = \Joomla\CMS\Factory::getUser()->get('id');
return;
I just added the variables there so I could dump them and they show the correct filename:
path: C:\xampp\apps\joomla\htdocs
def: C:\xampp\apps\joomla\htdocs\includes\defines.php
fq: C:\xampp\apps\joomla\htdocs\includes\framework.php
If I run cmd.exe and use:
TYPE C:\xampp\apps\joomla\htdocs\includes\defines.php
it shows the correct file, so it HAS the correct folder structure. The code to get the app and document work in a class that I use all over the place, but when I use that class here, it also fails.
I am using Joomla 4.2.8 and the latest Modals as of this morning. I'm using PHP 7.4.33.
I really hope you can put me out of my misery and point me in the right direction!!! <g>
Many thanks in advance for any guidance you can provide.
Best regards,