8
votes
JFactory::getDbo() deprecated-- what's the replacement?
If you are developing your extension only for Joomla 4.0+, you can replace
$db = Factory::getDbo();
with
$db = Factory::getContainer()->get('DatabaseDriver');
7
votes
JFactory::getDbo() deprecated-- what's the replacement?
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....
6
votes
Accepted
JFactory::getDbo() deprecated-- what's the replacement?
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 ...
6
votes
Accepted
Joomla extension update 3.x and 4.x
Based on this link that Roland Dalmulder sent me to:
https://github.com/joomla/joomla-cms/blob/5fdba4e5ee022517a05ae893d8f7077eaf864bf7/libraries/src/Updater/Adapter/ExtensionAdapter.php#L113
...
6
votes
Accepted
Joomla 4 create article programmatically
I rewrote the "Content Uploader" for Joomla 4 because I couldn't reach the developer. I had exactly the same problem as you described in the first example.
The reason is that the Workflow ...
6
votes
Accepted
Change database password?
The correct method is to update database password first, either via your hosting control panel or the command line.
Then manually update the password in configuration.php either through the File ...
5
votes
Accepted
How to use HTMLHelper to add to the document head
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 ...
5
votes
'getErrorMsg' is deprecated in Joomla 4 and what would be the equivalent
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 ...
5
votes
Joomla 4 create article programmatically
This will work.
$newapp = JFactory::getApplication();
$mvcFactory = $newapp->bootComponent('com_content')->getMVCFactory();
$articleModel = $mvcFactory->createModel('Article', 'Administrator',...
5
votes
Accepted
Prefill subform with data rows
You need to put the subform data one array deeper. This is because your subform has multiple attribute which means the data should be represented by multiple rows:
$prefillData = array("contacts&...
5
votes
Accepted
Can I delay loading a css file until a user is logged in?
Very interesting and good question in my opinion.
For this task I would use the 'joomla_user_state' cookie which is available from your template index.php file. (otherwise you can do this form a ...
5
votes
Accepted
How to programatically create a user in Joomla 4.x
Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
Joomla uses this line for creating an empty User object around line 287 in ..\libraries\src\User\User.php
// If the $...
4
votes
Accepted
Get Framework and template params in Joomla 4
define('_JEXEC', 1);
define('JPATH_BASE', __DIR__ . '/../../..');
require JPATH_BASE . '/includes/defines.php';
require JPATH_BASE . '/includes/framework.php';
// Boot the DI container.
$container = \...
4
votes
Menu Model Item in Joomla 4
To get Menu item in Joomla 4 you can get the Item From the Factory like
use Joomla\CMS\Factory;
$menu = Factory::getApplication()->getMenu();
$active = $menu->getActive();
getActive() will ...
4
votes
Accepted
Class not found in Joomla 4 when using JDate inside a function
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 ...
4
votes
Accepted
How to use cache calls in Joomla 4
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:
https://github.com/...
4
votes
Accepted
Update from 3.9.x to 4.x
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....
4
votes
Accepted
Best Practice: Loading component Styles & Scripts in J4
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 ...
4
votes
Accepted
Is Joomla4 API/Web Service ready for production use?
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 ...
4
votes
jQuery scripts not working in Joomla 4 template
Yes, for the most part J4 uses vanilla JavaScript and dependencies like jQuery should be loaded only when needed. If it's needed by your template's script files, you can add it as dependency in your ...
4
votes
Is the following everything one should do to prevent SQL injection?
First, when reading user input you should make sure it's the correct type. The Input/Filter APIs don't handle array/string conversion. So if you're expecting STRING filter to return a string be aware ...
4
votes
JRequest Method in Joomla 4
Use Joomla\Input\Input class. Instance relevant to the current request can be accessed through the application:
use Joomla\CMS\Factory;
$controller->execute(Factory::getApplication()->getInput()...
4
votes
Joomla 4 API Question
Academic explanation of J! 4 webservices route mapping
This is an explanation of how Joomla 4 (hereafter referred to as J! 4) webservices route resolution and method finding works.
Disclaimer What ...
4
votes
Accepted
How to show list of articles filtered by category and custom field
You can filter on Custom Fields via multiple ways:
filtering via JavaScript + CSS. This will load all articles, but can CSS hide (display:none) them using some JavaScript. The articles are still ...
4
votes
How to create a (better) development environment for Joomla 4
I've not used Docker so I can't help with that, but I have xdebug set up on my local environment in combination with PHPStorm and that is a big help in enabling me to figure out why something's not ...
3
votes
Accepted
Proper way for autoloading in Joomla 4
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:
use Joomla\Component\Fields\...
3
votes
Accepted
How to get the currently installed Joomla! Version in PHP
Use JVERSION constant. It holds the value returned by Joomla\CMS\Version::getShortVersion().
3
votes
Accepted
Where are plugins found in Joomla 4?
You probably work with Joomla 4 (alpha) as beta does not seem to be yet available. The plugins in Joomla 4 (alpha 7 latest) are at administrator->system->manage->plugins.
3
votes
Accepted
Joomla4 plugin getBody
According to the documentation, JApplicationWeb seems to be alive and well in Joomla4.
since 2.5.0
note As of 4.0 this class will be abstract
The getters:
JApplicationWeb::getBody()
Or
...
3
votes
Accepted
Joomla 4 - how to set namespace for custom field addfieldprefix
To implement Joomla standard namespacing in a plugin, follow these steps:
First, declare extension's namespace in manifest file:
<namespace>Joomla\Plugin\EditorsXtd\Vimeo</namespace>
If ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
joomla-4.x × 425php × 36
custom-component × 32
custom-field × 27
joomla-3.x × 26
joomla-4 × 23
component × 22
joomla-api × 20
development × 18
plugin × 17
mysql × 14
extensions × 13
javascript × 13
css × 12
database × 11
ajax × 11
router × 11
articles × 10
administrator × 10
html × 10
templates × 9
overrides × 9
form-fields-types × 9
module × 8
sef × 8