Joomla - 管理面板中的动态下拉列表

2022-01-06 00:00:00 php javascript joomla

我在 Joomla 的管理面板中向我的用户创建表单添加了一个下拉列表!1.5(使用 .xml 文件).我的问题是它的内容必须是动态的(来自外部源文件).我的问题是我可以在哪里(以及如何)做到这一点.

I have added a dropdown list to my user creation form in admin panel in Joomla! 1.5 (using .xml files). The problem I have is that the content of it must be dynamic (comes from an external source file). My question is where (and possibly how) I can make it.

推荐答案

您可以创建自己的类型.在您的 default.xml 中,您将拥有如下内容:

you can create your own type. At your default.xml you will have something like:

<url addpath="/administrator/components/com_componentname/elements/">
    <param name="id" type="myType" default="0" label="SELECT_LABEL" description="SELECT_DESC" />
</url>

并在/administrato/components/com_componentname/elements/myType.php 中实现

and as implementation in /administrato/components/com_componentname/elements/myType.php

class JElementmyType extends JElement {
    var     $_name = 'myType';

    function fetchElement($name, $value, &$node, $control_name)
    {

            $list = READ_FILE_OR_DB_OR_ANYTHING();
            array_unshift($list, JHTML::_('select.option', '0', '-'.JText::_('Select Me').' -', 'value', 'text'));

            return JHTML::_('select.genericlist',  $list, ''.$control_name.'['.$name.']', 'class="inputbox"', 'value', 'text', $value, $control_name.$name );
    }

}

相关文章