Php Joomla 1.6从1.5升级
这是将自定义参数类型添加到模块中的方法的文档,如果您查看下一轮,则有一行:将参数值保存到数据库中 有人能告诉我Joomla 1.6中是否有关于如何执行此操作的文档,因为我在任何地方都找不到它 我完全理解这是如何工作的,但是,您需要将自定义选项(例如:来自多个选择输入框的列表选择)绑定到父项,以便它能够将选择保存到DB 先谢谢你 编辑添加的代码Php Joomla 1.6从1.5升级,php,joomla,joomla1.6,Php,Joomla,Joomla1.6,这是将自定义参数类型添加到模块中的方法的文档,如果您查看下一轮,则有一行:将参数值保存到数据库中 有人能告诉我Joomla 1.6中是否有关于如何执行此操作的文档,因为我在任何地方都找不到它 我完全理解这是如何工作的,但是,您需要将自定义选项(例如:来自多个选择输入框的列表选择)绑定到父项,以便它能够将选择保存到DB 先谢谢你 编辑添加的代码 protected function getInput() { $options = array(); $att
protected function getInput()
{
$options = array();
$attr = '';
$attr .= ' multiple="multiple"';
$attr .= ' style="width:220px;height:160px;"';
// Get the database instance
$db = JFactory::getDbo();
// Build the select query
$query = 'SELECT params FROM jos_modules'
. ' WHERE module="mod_pmailer_subscription"';
$db->setQuery($query);
$params = $db->loadObjectList();
// Decode the options to get thje api key and url
$options = json_decode($params[0]->params, true);
// Create a new API utility class
$api = new PMailerSubscriptionApiV1_0(
$options['enterprise_url'],
$options['pmailer_api_key']
);
// Get the lists needed for subscription
$response = $api->getLists();
// Make a default entry for the dropdown
$lists = array('0' => 'Please select a list');
// Builds the options for the dropdown
foreach ( $response['data'] as $list )
{
$lists[$list['list_id']]['id'] = $list['list_id'];
$lists[$list['list_id']]['title'] = $list['list_name'];
}
// The dropdown output
return JHTML::_(
'select.genericlist',
$lists,
'jform[params][list_id]',
trim($attr),
'id',
'title',
$options['list_id']
);
}
签出,如何将JParams转换为JForm
编辑:
我查看了论坛,发现您正在使用
// Builds the options for the dropdown
foreach ( $response['data'] as $list )
{
$lists[$list['list_id']] = $list['list_name'];
}
但在JHTML中,传递文本和值字段的id和标题
使用
有趣的是,我已经看过了这个文档,但是没有关于如何实现getInput()的实际示例:“用受保护的函数getInput()替换函数fetchElement($name,$value,&$node,$control_name)”。您是否尝试过1.6中的1.5元素代码。我这样做没有任何问题。
那么您仍然需要在新的JForm字段中替换对$control\u name和其他名称的引用,但至少大部分工作已经自动完成了
您在谈论这个吗?父类JFormField有一个名为protected$formControl的受保护变量
@etbal:让我知道你到底想做什么?我已经实现了它,但它仍然没有将选择保存到模块参数字段中。我现在将编辑我的问题并添加代码
// Builds the options for the dropdown
foreach ( $response['data'] as $list )
{
$lists[$list['list_id']]['id'] = $list['list_id'];
$lists[$list['list_id']]['title'] = $list['list_name'];
}