简体   繁体   English

使用参数创建joomla模块

[英]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. 我是joomla 2.5的新手,我在看有关如何创建模块的joomla教程,但没有关于如何向其添加参数的内容。 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. 这样,管理员将设置新消息,我可以使用helper.php文件将其返回。

In the xml file i had to add : 在xml文件中,我必须添加:

<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: 然后在helper.php文件中,我在类的getMessage函数中编写了此代码:

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. 就是这样,当然不要忘记添加$ params作为函数的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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