2011-05-05 126 views
1

http://docs.joomla.org/Adding_a_multiple_item_select_list_parameter_type的Joomla 1.6升級1.5

爲一個自定義的參數類型添加到您的模塊和方法的文檔那是,如果你看一下底輪有這樣一行:保存參數值到數據庫

請有人告訴我,如果有任何關於如何在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'] 
     ); 

    } 

回答

3

結帳this,如何JParams轉換爲JForm

編輯:

我檢查了論壇,發現使用的是

// Builds the options for the dropdown 
foreach ($response['data'] as $list) 
{ 
    $lists[$list['list_id']] = $list['list_name']; 
} 

但在JHTML中,您傳遞了文本和val的標識和標題UE場,

使用

// 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']; 
    } 
+0

它有趣我已經看過這個文件了,不過還有的getInput()需要如何實現沒有真實的例子:「替代函數fetchElement($名稱,$值,&$ node,$ control_name)和保護函數getInput()「 – 2011-05-06 07:22:57

+0

沒有人可以幫我嗎? – 2011-05-09 12:03:58

+0

您是否嘗試過1.6中的1.5元素代碼。我沒有任何問題。 – Gaurav 2011-05-09 12:23:19