I am trying Joomla 4.
My biggest problem is to migrate the get article id functionality.

In Joomla 3.x, I used:

defined('_JEXEC') or die;    
$id= JRequest::getInt('id');

but this is not longer supported. So I now use:

use Joomla\CMS\Factory;
$app = Factory::getApplication();
$id   = $app->input->getCmd('id', '');

Is this really the best way to get the article id inside a PHP script?

  • 2
    Personally I'd use getInt() as opposed to getCmd() for stricter filtering. I don't know if there is a better way to get the article ID though – Lodder Jan 12 at 17:35

Your Answer

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

Browse other questions tagged or ask your own question.