编辑joomla组件以创建自定义字段

时间:2014-11-07 10:48:52

标签: php joomla2.5 custom-fields

我想制作一个带有多选下拉列表的joomla模块,其中包含菜单类别(如主菜单,产品菜单等)。经过一些研究后我发现,对于select,我们使用了一些组件并编辑/覆盖它们。我找到了一个带有联系人下拉列表的例子,他使用了这个xml代码:

<field
name="catid"
type="category"
extension="com_contact"
multiple="true"
default=""
size="10"
label="JCATEGORY">

和这个帮助代码:

<?php
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JModel::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_contact/models','ContactModel');
class modtestHelper
{
public function getList(&$params)
{
$app= JFactory::getApplication();
$db= JFactory::getDbo();
$model= JModel::getInstance('Contacts', 'ContactModel',array('ignore_request' => true));
$appParams = JFactory::getApplication()->getParams();
$model->setState('params', $appPaParams);
$model->setState('list.start', 0);
$model->setState('list.limit', (int) $params->get('count',5));
$model->setState('filter.published', 1);
$model->setState('list.select', 'a.id, a.name, a.catid' . ', a.address, a.suburb, a.postcode, a.state,a.telephone ' .', a.published, a.access, a.ordering, a.language'.', a.publish_up, a.publish_down');
$access = !JComponentHelper::getParams('com_contact')->get('show_noauth');
$authorised =JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
$model->setState('filter.access', $access);
$model->setState('filter.category_id', $params->get('catid', array()));
$model->setState('filter.language',$app->getLanguageFilter());
$model->setState('list.ordering', 'ordering');
$model->setState('list.direction', 'ASC');
$items = $model->getItems();
return $items;
}
}

乍一看,虽然com_contacts是每个下拉列表的组件,但是在我调整了这个http://pastebin.com/m9kFpmvs之后(这是一个很大的,所以我粘贴在这里)

$model= JModel::getInstance('Contacts', 'ContactModel',array('ignore_request' => true));

我看到它有像theese那样的自定义字段:

[0] => id
[1] => a.id
[2] => name
[3] => a.name

所以我现在需要的是: 到目前为止,我可以想象com_contact对我没用,我想问一下是否有人知道我可以用来为菜单制作多选下拉列表的不同组件,如果一个大师可以解释我,请问我找到的代码究竟是多少在示例中,当我没有看到任何正在执行的查询时获取结果。它连接到DB

$db= JFactory::getDbo();

但我根本找不到任何查询。 提前致谢

0 个答案:

没有答案