简体   繁体   中英

Create joomla module with parameters

I'm new to joomla 2.5 and I was looking at joomla tutorials on how we can create modules, but there's nothing about how can we add parameters to it. What I did for now is that I created a module that display a hello world message to my page and now I want to have a parameter in my module with a label your message. This way, the administrator will set the new message and I can return it using the helper.php file.

In the xml file i had to add :

<config>
        <fields name="params">
                <fieldset name="basic">
                        <field name="message"  type="text" default="https://osis.extranet.marseille-provence.fr/signalement/new" label="Lien de la page" description="Lien de la page à ouvrir." />
                </fieldset>
        </fields>
</config>

then in the helper.php file i wrote this in getMessage function of my class:

jimport('joomla.application.module.helper');
$msg = $params->get('message', 'hello world');
return $msg;

And that's it, of course don't forget to add $params as parameter of your function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM