[英]Joomla 1.6 Upgrade from 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']
);
}
簽出這個,如何將 JParams 轉換為 JForm
編輯:
我查看了論壇,發現您正在使用
// Builds the options for the dropdown
foreach ( $response['data'] as $list )
{
$lists[$list['list_id']] = $list['list_name'];
}
但是在 JHTML 中,您正在為文本和值字段傳遞 id 和標題,
利用
// 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'];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.