As a sort of newbie developer with php/Joomla, I created a content plugin for Joomla 3 which pretty much did what I wanted and expected...
I then decided to migrate it to Joomla 4 following the very few examples that I could google here and there and nothing works. In fact, the plugin doesn't even seem to load.
So, I decided to get back to a very simple sort of helloworld type thing test and even this test doesn't do anything. I should add that install and activation work and no error message is ever displayed when setting to Maximum.
Here's the very simple thing I tried:
<?php
defined('_JEXEC') or die;
use Joomla\CMS\Plugin\CMSPlugin;
class PlgContentTest extends CMSPlugin
{
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
if ($context !== 'com_content.article')
{
echo 'Wrong!';
return;
}
echo 'Here!';
}
}
?>
I cannot figure out what I've done wrong here, except maybe something about file naming?
My xml:
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="4.0" method="upgrade" group="content">
<name>Test</name>
<author></author>
<creationDate>January 2022</creationDate>
<copyright>Copyright (C) 2022+ . All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>1.5</version>
<description>PLG_CONTENT_TEST_DESCRIPTION</description>
<files>
<filename plugin="Test">Test.php</filename>
<filename>index.html</filename>
</files>
<languages folder="administrator/language">
<language tag="en-GB">language/en-GB/en-GB.plg_content_Test.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_content_Test.sys.ini</language>
<language tag="fr-FR">language/fr-FR/fr-FR.plg_content_Test.ini</language>
<language tag="fr-FR">language/fr-FR/fr-FR.plg_content_Test.sys.ini</language>
<languages>
</extension>