The development strategy for the Joomla CMS is currently being revised. There is going to be at least a 3.3 and a 3.4 and probably more incremental minor versions at irregular intervals. This is different from the previous pattern where we'd go 3.5 and then 4.0 six months apart. It's not known when 4.0 will be released but my guess is it's not going to be ...
Joomla 3.9.x has a file public_html/libraries/classmap.php that contains all the old style Class names, and the new replacements. E.g.
JLoader::registerAlias('JFactory', '\\Joomla\\CMS\\Factory', '5.0');
JFactory is indeed deprecated. You can rewrite
// JFactory is deprecated
$db = JFactory::getDbo();
// Put at the top of your file
1) JHtml is an alias for Joomla\CMS\HTML\HTMLHelper class. You'll have to start using the real class sooner or later because the alias will not exist in Joomla! 5.0. To use the real class you have to either import it:
Or use fully qualified class name:
Based on this link that Roland Dalmulder sent me to:
preg_match('/^' . $this->currentUpdate->targetplatform['VERSION'] . '/', JVERSION)
There is no implementation of preg_quote(), so the dots (any character / ...
You can download the full API collection here:
https://github.com/alexandreelise/j4x-api-collection thanks to Alexandre Elise.
This will import directly into Postman which will enable you to use the API simply by adding your key and URL to the collection.
To create a key you need to:
Make sure the plugins are enabled.
Make sure your user has a token
You need to wait for 3.10.X to become available; as per the documentation, "This guide assumes you are starting on Joomla 3.10.x. If you are on a earlier version make sure you upgrade to Joomla 3.10 first before moving to Joomla 4."
Joomla 3.10 is currently in development, at 86% completion, most notably, with no completion date for release. V3.10-...
This should still work in 4.0 but will break in 5.0. You are advised to use fully qualified class names. Remove JLoader::register() call and instead add a use statement:
Your issue comes solely from confusion about Joomla! versions. These facts should clear the air:
\Joomla\CMS\Factory::getDbo() is deprecated in 4.0 and will be removed in 5.0. It is alive and well in 3.9.
\Joomla\CMS\Factory::getContainer() doesn't exist in 3.9 as it was only added in 4.0.
The code you were looking at is from 4.0, not from 3.9.5.
I’m answering the question because it is obviously not a Joomla 4 core bug but a mistake in the developer’s coding and the problem would be the same in Joomla 3 too.
If you try to use a Joomla core class in your code you have to include that class on the top of the file otherwise Joomla does not know what it needs to use, so:
In Joomla 4 we've completely removed the Mootools library and any API functions for it. If you'd like to utilise a modal, you can use JHtmlBootstrap::renderModal which is currently a wrapper for Bootstraps JS modal component, however we're rewriting the main components as custom elements.
Here is an example for you to build on top of:
// Add this to the ...
To get Menu item in Joomla 4 you can get the Item From the Factory like
$menu = Factory::getApplication()->getMenu();
$active = $menu->getActive();
getActive() will give the curent Menu Item, you can use other methods getDefault() or getItem() as per your need.
You can get Menu items with menu type as
$items = $menu->...
Both have pros and cons.
Web Asset Manager is great if your loading an asset that depends on another one. For example:
some jQuery plugin
that depends on jQuery
Your json file can set jQuery as a dependency, meaning you don't need to manually import it.
If you're loading a single file that has no dependencies, then the Web Asset Manager has a lot of ...
Use the fully qualified class name which is Joomla\CMS\Helper\ModuleHelper.
To get this information in your IDE, you can run build/stubGenerator.php script via PHP command line. This will generate a stub file of deprecated class aliases and the new classes to use. This is how it looks in VS code:
I try to give just a short answer on this. We cannot say that there is an “equivalent” of your code snippet in Joomla 4 since Joomla has been handling errors with using core PHP Exceptions. And your code sample would get error in newer Joomla 3 also.
The old JError class were deprecated quite long time ago (at Joomla 3.1). The code editors shows this ...
Any component that is an instance of Joomla\CMS\Extension\LegacyComponent. This includes:
J3 style components that do not have services/provider.php file returning a service provider.
J4 components that do not provide an implementation of Joomla\CMS\Extension\ComponentInterface.
J4 components that provide an instance of Joomla\CMS\Extension\...
Your comment led me to doubt my belief that getDbo() is alive and well. I have tested my below techniques on Joomla3.9.5 and there are no problems.
Based on this documentation:
Returns the global \JDatabaseDriver object, only creating it if it doesn't already ...
define('JPATH_BASE', __DIR__ . '/../../..');
require JPATH_BASE . '/includes/defines.php';
require JPATH_BASE . '/includes/framework.php';
// Boot the DI container.
$container = \Joomla\CMS\Factory::getContainer();
// Alias the session service key to the web session service.
Finally figured it out - my problem is a missing placeholder in the tmpl (which was not required for JSubMenuHelper). Added this to my tmpl/default.php, now it works:
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
The submenu in banners I was wondering about is actually done via the manifest file, ...
Either, include that helper class on the top of your default.php like:
defined('_JEXEC') or die;
Then you can use that class within your default.php file
Or standardly define your own variable in mod_articles_latest.php like:
$myStuffHere = ArticlesLatestHelper::myCustomFunction($myparam)...
According to the documentation, JApplicationWeb seems to be alive and well in Joomla4.
note As of 4.0 this class will be abstract
Relevant references and ...
Thanks to @Zollie-- the plugin is enabled by default and does seem to work. You'd need to check the libraries/autoload_psr4.php to verify that your component's namespace (set in the new namespace parameter in the manifest xml) is being generated correctly.
The default namespace format for custom components is DeveloperName\Component\ComponentName.
Just an FYI that Joomla 3.10-alpha has now been released so the upgrade process can now easily done.
Go to the Joomla Update Component Options and switch the Update Channel to Testing and the Minimum Stability option to Alpha.
Update to 3.10 alpha1 using the Joomla Update Component.
After you have updated to 3.10 alpha please switch the Update
The call method has been marked as removed for Joomla 4.0, as it's simply a wrapper for get().
You don't need to manually store the cache as this is done within the get() method:
If you want to translate the variables, you need to do it before passing them to Text::sprintf():
This hasn't changed since J3 and Joomla\CMS\Language\Text::sprintf() is not deprecated in J4.
$document->addScriptDeclaration() method is working, no problem with that.
window.event is deprecated:
instead of that you should use document.addEventListener() or window.addEventListener() on the event of DOMContentLoaded
You are using onAfterRender event which is not suitable for modifying the document object because this event is triggered after the page has already been rendered. Use onAfterDispatch, onBeforeRender or onBeforeCompileHead instead.