0

enter image description here

By default, under category option, only could add one image. I want to insert second image. I made a plugin to extend category.xml, but it doesn't work.

Plugin files:

categorydrawing.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="content" method="upgrade">
    <name>plg_category_drawing_image</name>
    <description>To add an drawing image to category</description>
    <files>
        <filename plugin="categorydrawing">categorydrawing.php</filename>
        <folder>params</folder>
    </files>
</extension>

categorydrawing.php

<?php
// no direct access
defined ('_JEXEC') or die;
class plgContentExample extends JPlugin
{
    /**
     * Load the language file on instantiation.
     * Note this is only available in Joomla 3.1 and higher.
     * If you want to support 3.0 series you must override the constructor
     *
     * @var boolean
     * @since <1.0>
     */
    protected $autoloadLanguage = true;

    /**
     * Prepare form and add my field.
     *
     * @param   JForm  $form  The form to be altered.
     * @param   mixed  $data  The associated data for the form.
     *
     * @return  boolean
     *
     * @since   <1.0>
     */
    function onContentPrepareForm($form, $data)
    {
        $app    = JFactory::getApplication();
        $option = $app->input->get('option');

        switch($option)
        {
            case 'com_categories' :
                if ($app->isClient('administrator'))
                {
                    JForm::addFormPath(__DIR__ . '/forms');
                    $form->loadFile('category', false);
                }

                return true;
        }

        return true;
    }
}
?>
zhang
  • 1
  • 1

1 Answers1

0

categorydrawingimage.xml

<?xml version="1.0" encoding="UTF-8"?>
<form>
    <fields addfieldprefix="Joomla\Component\Categories\Administrator\Field">
        <fieldset name="drawing_image_params" label="Drawing Image">
            
                <field
                    name="drawing_image"
                    type="media"
                    label="Drawing Image"
                />

                <field
                    name="drawing_image_alt"
                    type="text"
                    label="Drawing Image Description (Alt Text)"
                />
        </fieldset>
    </fields>
</form>
zhang
  • 1
  • 1