在我的自定义组件中使用 joomla com_media 图像选择 [英] use joomla com_media image selection in my custom component

查看:12
本文介绍了在我的自定义组件中使用 joomla com_media 图像选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

hi i want to use com_media image selection in my own component. the link is:

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

图片转到编辑器,而我想要它的地址转到

the image goes to editor while i want it's address go to

<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

i am using joomla 1.5

有什么建议吗?

谢谢

推荐答案

如果您使用的是 Joomla 1.6,那么简单的方法就是让 Joomla 为您完成所有工作.怎么样?

If you're using Joomla 1.6 the easy way is let Joomla do all the work for you. How?

首先,您需要在 xml 表单 (/model/forms/YOURFORM.xml) 中包含类似的内容...

First you need to include in you xml form (/model/forms/YOURFORM.xml) something like that...

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

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

Haven't you got a getForm() in your model?

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(), "
";
        }

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


        return $form;
    }

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

In your view (/views/xxxx/view.html.php) you need to load your form

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

最后你只需要在你想要的任何地方打印模板中的元素.

Finally you only need to print the element in the template wherever you want.

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

再见

这篇关于在我的自定义组件中使用 joomla com_media 图像选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆