0

嗨,我想在我自己的组件中使用 com_media 图像选择。链接是:

index.php?option=com_media&view=images&tmpl=component&
e_name=smallimage

图像转到编辑器,而我希望它的地址转到

<input class="inputbox" type="text" name="smallimage" id="smallimage" size="40" 
maxlength="255" value="<?php echo $row->smallimage; ?>" title=
"<?php echo JText::_('SMALLIMAGETIP' ); ?>" />

我正在使用 joomla 1.5

有什么建议吗?

谢谢

4

2 回答 2

3

如果您使用的是 Joomla 1.6,简单的方法是让 Joomla 为您完成所有工作。如何?

首先你需要在你的xml表单(/model/forms/YOURFORM.xml)中包含类似的东西......

<field name="imageurl" type="media" directory="CUSTOMDIRECTORY?"
                hide_none="1" label="COM_YOURCOMPONENT_IMG_LABEL"
                size="40"
                description="COM_YOURCOMPONENT_IMG_DESCRIPTION" />

您的模型中没有 getForm() 吗?

public function getForm($data = array(), $loadData = true)
    {

        // Get the form.
        try {
            //throw new Exception(JText::_('JLIB_FORM_ERROR_NO_DATA'));
            $form = $this->loadForm('com_kfiles', 'files');
        } catch (Exception $e) {
            echo "e";
            echo 'Caught exception: ',  $e->getMessage(), "\n";
        }

        if (empty($form)) {
            return false;
        }


        return $form;
    }

在您的视图(/views/xxxx/view.html.php)中,您需要加载表单

$this->form = $this->get('Form');

最后,您只需要将模板中的元素打印到您想要的任何位置。

echo $this->form->getLabel('imageurl'); 
echo $this->form->getInput('imageurl');

再见

于 2011-04-12T07:44:55.003 回答
1

不是直截了当,但你可以像这里提到的那样解决 - Joomla 论坛

于 2011-04-02T03:52:53.300 回答