Joomla 1.6 从 1.5 升级

发布于 2024-11-05 07:03:18 字数 1934 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执着的年纪 2024-11-12 07:03:18

查看这个,如何将 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'];
    }

Checkout this, How to convert JParams to JForm

EDIT :

I checked the forum and found that you are using

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

but in JHTML you are passing id and title for text and value field,

Use

    // 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'];
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文