phpjoomlajoomla3.1

How to add back-end form field parameters in a Joomla Module?


I checked out this article Creating a simple module/Developing a Basic Module for building a basic Joomla module. I understood the MVC architecture and file structure they've mentioned there. It is a simple Hello World module for Joomla.

Now I want to modify this module in a way that it accepts whatever text I enter (instead of static "Hello World") from Joomla back-end. What I don't get is, how to or where to enter the code for the text-box field that gets displayed in Joomla back-end of this module?

In short, the link above doesn't mention anything about entering back-end parameters for a module. How to do that?


Solution

  • You define parameters in the XML file like so:

    <config>
        <fields name="params">
            <fieldset name="basic">
                <field name="param1" type="text" default="" label="" description="">
                <field name="param2" type="text" default="" label="" description="">
                <field name="param3" type="text" default="" label="" description="">
                // add more here
            </fieldset>
        </fields>
    </config>
    

    And you can call them like so:

    echo $params->get('param1');
    echo $params->get('param2');
    // and so on
    

    Hope this helps