Joomla 1.6 Обновление с 1.5 - PullRequest
1 голос
/ 05 мая 2011

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']
        );

    }

1 Ответ

3 голосов
/ 05 мая 2011

Оформление заказа это , Как конвертировать JParams в JForm

РЕДАКТИРОВАТЬ:

Я проверил форум и обнаружил, что вы используете

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

но в JHTML вы передаете идентификатор и заголовок для поля текста и значения,

Использование

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