2

i'm trying to edit joomla's category form with a plugin following this guide https://docs.joomla.org/Creating_a_profile_plugin

xml file

<extension version="3.1" type="plugin" group="category">
    <name>plg_img_categories</name>     
    <files>
        <filename plugin="categories">categoryimg.php</filename>
        <folder>forms</folder>
    </files>

</extension>

php file

<?php
defined( '_JEXEC' ) or die;

class plgContentCategoryCategories extends JPlugin {
    function onContentPrepareForm($form, $data) {
        echo "Pippo!";
        var_dump($form->getName());
    }
 }
?>

I was expected to see var_dump "$form->getName()" or "Pippo!" inside the administrator category form, however it doesn't.

Any idea why?

1

There is no plugin group like category, you should use content in this case.

Joomla! relies strongly on naming conventions:

  • Class name should be plg[GROUP_NAME][PLUGIN_ATTR_VALUE], resulting in plgContentCategoryImg
  • Plugin name in XML should be plg_[GROUP_NAME]_[PLUGIN_ATTR_VALUE], resulting in plg_content_categoryimg.
  • Plugin directory name must be [PLUGIN_ATTR_VALUE], resulting in categoryimg

So, your files would look like this:

categoryimg.php

<?php
defined( '_JEXEC' ) or die;

class plgContentCategoryImg extends JPlugin {
    function onContentPrepareForm($form, $data) {
        echo "Pippo!";
        var_dump($form->getName());
    }
 }
?>

categoryimg.xml

<extension version="3.1" type="plugin" group="content">
    <name>plg_content_categoryimg</name>
    <files>
        <filename plugin="categoryimg">categoryimg.php</filename>
    </files>
</extension>

And don't forget, directory name must be categoryimg.

Result as I tested it:

enter image description here

| improve this answer | |
  • You are my HERO! Thanks mate! – Umberto Nov 5 '16 at 15:06

Your Answer

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

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