0

I have made other plugins for Joomla 4 but I am still a novice. The past two days I have been searching for a solution, it's becoming quite frustrating. I have brought back my code in the php file to just to show me anything, in this case 'Hello There'. I have searched reporting, the log just shows it loads the plugin and nothing... The plugin does install correctly, uninstalls too, the shortcode is simple {climate} and all the files are in place, Joomla also finds the plugin because I have tested it even on a clean install of Joomla 4. Just the onContentPrepare doesnt do anything at all which is weird.. Can anyone help me?? :

<?php
/**
 * @version    1.0.0
 * @package    myclimatetable (plugin)
 * @author     AN
 * @copyright  Copyright (c) 2023 AN
 * @license    GNU/GPL license: https://www.gnu.org/copyleft/gpl.html
 */

// No direct access
defined('_JEXEC') or die;

class PlgContentClimateTable extends JPlugin 
{
    public function onContentPrepare($context, &$article, &$params, $limitstart) 
    {
        $article->text = preg_replace('/{climate}/', 'Hello there', $article->text);
        return true;
    }
}

My manifest file is okay, I think.

<?xml version="1.0" encoding="utf-8"?>
<extension version="4.0" type="plugin" group="content" method="upgrade">
    <name>plg_content_myclimatetable</name>
    <author>AN</author>
    <creationDate>September 2023</creationDate>
    <copyright>Copyright (C) 2023 Harper Douglas Max</copyright>
    <license>NU/GPL license: https://www.gnu.org/copyleft/gpl.html</license>
    <authorEmail>AN</authorEmail>
    <authorUrl>AN</authorUrl>
    <version>0.02</version>
    <description>A plugin that allows climate tables to be inserted from WMO</description>

    <!-- Files and folders included in the plugin -->
    <files>
        <filename plugin="myclimatetable">myclimatetable.php</filename>
        <filename>index.php</filename>
        <filename>full_city_list.csv</filename>
        <folder>language</folder>
        <folder>tmpl</folder>
        <folder>logs</folder>
    </files>
    <languages folder="language">
        <language tag="en-GB">en-GB/en-GB.plg_content_myclimatetable.sys.ini</language>
        <language tag="en-GB">en-GB/en-GB.plg_content_myclimatetable.ini</language>
        <language tag="nl-NL">nl-NL/nl-NL.plg_content_myclimatetable.sys.ini</language>
        <language tag="nl-NL">nl-NL/nl-NL.plg_content_myclimatetable.ini</language>
    </languages>
</extension>

1 Answer 1

0

Per documentation, the class name should be in format plg<PluginGroup><PluginName> (casing doesn't matter for J3 and older style plugins). The name of your plugin is myclimatetable, as defined by plugin attribute in the XML file. Therefore, the class name should be PlgContentMyClimateTable, not PlgContentClimateTable.

1
  • Thank you so much! What a silly oversight!
    – EJBJane
    Sep 18, 2023 at 16:42

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.