List Joomla 2.5从字段获取选项(列表)

List Joomla 2.5从字段获取选项(列表),list,joomla,joomla2.5,field,options,List,Joomla,Joomla2.5,Field,Options,我不敢相信我会问这样的问题。我在谷歌上搜索了4个小时,只是为了找到解决方案。我发现了大约10000页关于如何在xml中创建字段的内容,但没有人知道如何在php代码中调用选项 我需要的是此字段中的选项数组: <field name="field8" type="jevcflist" default="-1" label="Alter" required="1" allowoverride="0" filter="1" access="0" size="1" style="min-width:

我不敢相信我会问这样的问题。我在谷歌上搜索了4个小时,只是为了找到解决方案。我发现了大约10000页关于如何在xml中创建字段的内容,但没有人知道如何在php代码中调用选项

我需要的是此字段中的选项数组:

<field name="field8" type="jevcflist" default="-1" label="Alter" required="1" allowoverride="0" filter="1" access="0" size="1" style="min-width: 123px;">
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
</field>
当I
var\u dump
时,
$field
的数据:

object(JFormFieldJevcflist)[428]
  protected 'node' => null
  protected 'type' => string 'List' (length=4)
  protected 'description' => string '' (length=0)
  protected 'element' => 
    object(JXMLElement)[427]
      public '@attributes' => 
        array (size=11)
          'name' => string 'field8' (length=6)
          'type' => string 'jevcflist' (length=9)
          'default' => string '-1' (length=2)
          'label' => string 'Alter' (length=5)
          'required' => string '1' (length=1)
          'allowoverride' => string '0' (length=1)
          'filter' => string '1' (length=1)
          'access' => string '0' (length=1)
          'size' => string '1' (length=1)
          'style' => string 'min-width: 123px;' (length=17)
          'class' => string 'required' (length=8)
      public 'option' => 
        array (size=10)
          0 => string '3' (length=11)
          1 => string '4' (length=11)
          2 => string '5' (length=11)
          3 => string '6' (length=11)
所以我尝试了
$field->element->option
,但根本不起作用。 我也应该有期权价值。。。 它在1.5中使用了JParameter,但在2.5中是如何实现的

编辑: 我需要一个过滤文件

谢谢你

编辑2: 按照Joomla 1.5的要求:

$hasage = false;

        $params = new JParameter(null, $xmlfile);

        foreach($params->_xml["_default"]->children() as $n) {
            if($n->_attributes['label']=="Alter") {
                $hasage = true;
                //foreach($n->children() as $param){
                foreach($n->_children as $param){
                    $options[] = JHTML::_('select.option',
                         $param->_attributes['value'], 
                         $param->_data, //"Ab ".$param->_attributes['value']." Jahren",
                         "value",
                         "customfieldage");
                }
            }
        }

        if (!$hasage){
            $filterList["title"] = "";
            $filterList["html"] = "";
            return $filterList;
        }

        /*for($i = 3; $i < 13; $i++) {
            $options[] = JHTML::_('select.option', $i, "Ab ".$i." Jahren", "value", "customfieldage");
        }*/

        $filterList["html"] = JHTML::_('select.genericlist',
                                $options,
                                $this->filterType.'_fv',
                                'onchange="this.form.submit();"',
                                'value',
                                'customfieldage',
                                $this->filter_value);



        $script = "JeventsFilters.filters.push({id:'".$this->filterType."_fv', value:-1});";
        $document = JFactory::getDocument();
        $document->addScriptDeclaration($script);

        return $filterList;
$hasage=false;
$params=新的JPParameter(null,$xmlfile);
foreach($params->_xml[“_default”]->children()作为$n){
如果($n->_属性['label']==“Alter”){
$hasage=true;
//foreach($n->children()作为$param){
foreach($n->_子项为$param){
$options[]=JHTML::(('select.option',
$param->_属性['value'],
$param->_数据,//“Ab”。$param->_属性['value'].“Jahren”,
“价值”,
"海关";;
}
}
}
如果(!$hasage){
$filterList[“title”]=“”;
$filterList[“html”]=“”;
返回$filterList;
}
/*对于($i=3;$i<13;$i++){
$options[]=JHTML::(('select.option',$i,“Ab.”,$i.Jahren,“value”,“customfieldage”);
}*/
$filterList[“html”]=JHTML::(('select.genericslist',
美元期权,
$this->filterType.“\u fv”,
'onchange=“this.form.submit();”,
“价值”,
“customfieldage”,
$this->filter_值);
$script=“JeventsFilters.filters.push({id:'”“$this->filterType。”_fv',value:-1});”;
$document=JFactory::getDocument();
$document->addScriptDeclaration($script);
返回$filterList;

你能用
JParameter
显示你用于Joomla 1.5的确切代码吗?@Lodder好的,我编辑了主要帖子。谢谢
$hasage = false;

        $params = new JParameter(null, $xmlfile);

        foreach($params->_xml["_default"]->children() as $n) {
            if($n->_attributes['label']=="Alter") {
                $hasage = true;
                //foreach($n->children() as $param){
                foreach($n->_children as $param){
                    $options[] = JHTML::_('select.option',
                         $param->_attributes['value'], 
                         $param->_data, //"Ab ".$param->_attributes['value']." Jahren",
                         "value",
                         "customfieldage");
                }
            }
        }

        if (!$hasage){
            $filterList["title"] = "";
            $filterList["html"] = "";
            return $filterList;
        }

        /*for($i = 3; $i < 13; $i++) {
            $options[] = JHTML::_('select.option', $i, "Ab ".$i." Jahren", "value", "customfieldage");
        }*/

        $filterList["html"] = JHTML::_('select.genericlist',
                                $options,
                                $this->filterType.'_fv',
                                'onchange="this.form.submit();"',
                                'value',
                                'customfieldage',
                                $this->filter_value);



        $script = "JeventsFilters.filters.push({id:'".$this->filterType."_fv', value:-1});";
        $document = JFactory::getDocument();
        $document->addScriptDeclaration($script);

        return $filterList;