0

How do I get the solution for this https://stackoverflow.com/questions/18975896/adding-category-parameters to work on Joomla 4?

My extension includes various categories, which I've named "[my_component].[category_name]" - can the dot on the extension name be a problem?

Thanks!

1 Answer 1

1

I tried this out and this worked for me:

<?xml version="1.0" encoding="utf-8"?>
<form>
    <fields name="params">
        <fieldset name="groups" label="Group settings">
            <field name="group_id" type="list" default="" label="Select group:">
                <option value=""></option>
                <option value="1">Group 1</option>
                <option value="2">Group 2</option>
                <option value="3">Group 3</option>
            </field>
        </fieldset>
    </fields>
</form>

I put it in the admin /forms folder and called the file category.two.xml (where 'two' is my category_name).

The other approach you might want to consider is to enable custom fields on your component, then you can add additional fields to your component's Category entity. How to enable them is described in the Joomla 3 MVC Tutorial Adding Custom Fields step. The work to do it in Joomla 4 is similar - you just have to move the getContexts() and validateSection() methods into your Extension class, and ensure that your extension class implements Joomla\CMS\Fields\FieldsServiceInterface.

1
  • Thanks @Robbie Jackson. The naming of the file solved my problem - the devil is in the details. Custom fields were my last resource - parameters are much better in this use case because of inheritance rules from component and menu parameters. Commented Jun 21, 2023 at 7:51

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.