Joomla 1.6 从 1.5 升级
http://docs.joomla.org/Adding_a_multiple_item_select_list_parameter_type
这是添加自定义参数类型的方法的文档到您的模块,如果您查看底部,就会看到这一行:将参数值保存到数据库
请有人告诉我是否有任何有关如何操作的文档这是 Joomla 1.6 中的因为我在任何地方都找不到它吗?
我完全理解这是如何工作的,您需要将自定义选项(例如:多选输入框中的列表选择)绑定到父级,以便能够将选择保存到数据库。
先感谢您。
编辑添加的代码
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']
);
}
http://docs.joomla.org/Adding_a_multiple_item_select_list_parameter_type
Thats the documentation for the way to add a custom parameter type to your module and if you look at the bottom round there is this line : Saving parameter values to a database
Please can someone tell me if there is any documentation on how to do this in Joomla 1.6 because I cannot find it anywhere?
I understand completely how this works though, You need to bind your custom options (example: the list selection from a multiple selection input box) to the parent so that it will be able to save the selection to the DB.
Thank you in advance.
EDIT added code
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']
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看这个,如何将 JParams 转换为 JForm
编辑:
我检查了论坛并发现您正在使用,
但在 JHTML 中您正在传递文本和值字段的 id 和标题,
使用
Checkout this, How to convert JParams to JForm
EDIT :
I checked the forum and found that you are using
but in JHTML you are passing id and title for text and value field,
Use