1

So within administrator function.

echo("<script>console.log('PHP: " . $data . "');</script>");

It seems it doesn't insert the js script on the page. This works from a simple PHP file, but not from Joomla. Any ideas?

1 Answer 1

1

You can use Joomla's Web Asset Manager to insert inline scripts via PHP, like so:

use Joomla\CMS\Factory;

$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->addInlineScript('console.log("PHP: ' . $data . '")');
3
  • Thanks, but the file which I want to debug looks like doesn't output anything at all. "\libraries\src\Form\Field\CalendarField.php"
    – Plamen
    Commented Apr 2, 2023 at 5:31
  • Can you not just var_dump($data)?
    – Lodder
    Commented Apr 2, 2023 at 6:07
  • Noting out. This is from "Articles: Edit - Publishing tab". Not sure, but no HTML output from CalendarField.php.
    – Plamen
    Commented Apr 2, 2023 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.