Joomla3.0 Joomla 3自定义字段获取xml字段

Joomla3.0 Joomla 3自定义字段获取xml字段,joomla3.0,joomla3.3,Joomla3.0,Joomla3.3,我正在创建一个自定义字段,以创建作为媒体类型的输入图像数组 如何将类型为media的输入阵列带回 class JFormFieldimglist extends JFormField { //The field class must know its own type through the variable $type. protected $type = 'imglist'; public function getLabel() {

我正在创建一个自定义字段,以创建作为媒体类型的输入图像数组

如何将类型为media的输入阵列带回

class JFormFieldimglist extends JFormField {

        //The field class must know its own type through the variable $type.
        protected $type = 'imglist';

        public function getLabel() {
                return "List Image";
        }

        public function getInput() {
          for ($i = 1; $i <= 10; $i++) {
          $images.= '<input type="text" value="'.$this->value[$i].'" name="'.$this->name.'['.$i.']" />';            
          }
             return $images;
        }
}
class JFormFieldimglist扩展了JFormField{
//field类必须通过变量$type知道自己的类型。
受保护的$type='imglist';
公共函数getLabel(){
返回“列表图像”;
}
公共函数getInput(){
对于($i=1;$i值[$i]。“name=“”。$this->name.['.$i.]”/>;
}
返回$images;
}
}
从xml中,我使用

<field name = "myimage" type = "media" directory = "stories" />

有两个问题。第一个问题是扩展核心JFormField类。第二个问题是媒体字段类型实际上是一个模式表单字段。这是一种特殊类型的字段,用于在模式窗口中显示更复杂的界面,供用户选择。例如,当您为其选择文章时单击菜单类型的单个文章,或单击所见即所得编辑器下方的图像按钮

我猜您想从特定文件夹中提取一个图像列表,供用户从下拉列表中选择。在下面的示例中,请注意,我完全省略了getLabel()和getInput()方法,并添加了getOptions()。原因是通过扩展JFormFieldList类,这些方法已经构建,不需要特殊要求之外的方法。只需重写getOptions()方法,即可为核心类提供希望在字段中显示的选项列表

jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');

class JFormFieldimglist extends JFormFieldList {

    //The field class must know its own type through the variable $type.
    protected $type = 'imglist';

    public function getOptions() {
        // build out your options array
        // You should format as array, with full path as key and 
        // human readable as value
        $options = array('/images/flowers/tulip.png' => 'Tulip');
        return $options;
    }
}
这里有一些链接可以在我的帖子上扩展