econveyors
Member
Hello,
I am working on updating my custom PHP code in Fabrik to work with J4/F4. All I really need to change are my calls to get the database connection. I'm following the instructions here: https://github.com/trobfab/fabrik/wiki/Upgrading-from-fabrik3.10-to-fabrik4
The site is currently on J3.10.11, Fabrik 3.10, PHP 7.4.33. I'm testing out the change in a Display element.
I've replaced
$mydb = JFactory::getDBO();
with
$mydb = version_compare(\Joomla\CMS\Version::MAJOR_VERSION, "4", ">=") ? Factory::getContainer()->get('DatabaseDriver') : Factory::getDbo();
When I view the list, I get this error
0 - Class 'JoomlaCMSVersion' not found
As a test, I put this code in the display element and removed all other code, just to see if I could call something using \Joomla\CMS\Factory.
$user = \Joomla\CMS\Factory::getUser();
return $user;
And I get this error:
0 - Class 'JoomlaCMSFactory' not found
Is there something specific I need to do to use this in an element's PHP code? I wouldn't think so, but I thought I'd double check.
I am working on updating my custom PHP code in Fabrik to work with J4/F4. All I really need to change are my calls to get the database connection. I'm following the instructions here: https://github.com/trobfab/fabrik/wiki/Upgrading-from-fabrik3.10-to-fabrik4
The site is currently on J3.10.11, Fabrik 3.10, PHP 7.4.33. I'm testing out the change in a Display element.
I've replaced
$mydb = JFactory::getDBO();
with
$mydb = version_compare(\Joomla\CMS\Version::MAJOR_VERSION, "4", ">=") ? Factory::getContainer()->get('DatabaseDriver') : Factory::getDbo();
When I view the list, I get this error
0 - Class 'JoomlaCMSVersion' not found
As a test, I put this code in the display element and removed all other code, just to see if I could call something using \Joomla\CMS\Factory.
$user = \Joomla\CMS\Factory::getUser();
return $user;
And I get this error:
0 - Class 'JoomlaCMSFactory' not found
Is there something specific I need to do to use this in an element's PHP code? I wouldn't think so, but I thought I'd double check.