【问题标题】:Prestashop custom module add table headerPrestashop 自定义模块添加表头
【发布时间】:2016-09-14 22:44:44
【问题描述】:

我正在 Prestashop 中开发一个自定义模块。在该模块中,我想显示我的自定义保存值,例如表格顺序。所以基本上表格应该有标题部分,在那个标题部分会有输入字段来搜索相应的数据标题的记录。所以模块自定义页眉应该像这个参考图片

那么有人可以告诉我如何在自定义模块中执行此操作吗?任何帮助和建议都将非常可观。谢谢

【问题讨论】:

  • 我的解决方案对您有用吗?

标签: prestashop prestashop-1.6


【解决方案1】:

除了显示表头之外,您需要付出一些努力才能使其正常工作,我希望您使用的是 HelperList 类,

$helper->simple_header = false;

检查official documentation

【讨论】:

    【解决方案2】:

    假设你知道如何制作一个模块,你所需要的就是这个(记住这是一个例子,你必须在这里和那里替换一些零碎的东西)。

    文件/modules/mymodule/controllers/admin/AdminRulesController.php

    class AdminRulesController extends ModuleAdminController
    {
        public function __construct()
        {
            $this->module = 'mymodule'; 
            $this->table = 'rules'; //table queried for the list
            $this->className = 'Rules';//class of the list items
            $this->lang = false;
            $this->bootstrap = true;
            $this->context = Context::getContext();
    
            $this->fields_list = array(
                'id_rule' => array(
                    'title' => $this->l('ID'),
                    'align' => 'center',
                    'class' => 'fixed-width-xs',
                    'search' => false, //in case you want certain fields to not be searchable/sortable
                    'orderby' => false,
                ),
                'name' => array(
                    'title' => $this->l('Rule name'),
                    'align' => 'center',
                ),
                'is_active' => array(
                    'title' => $this->l('Active'),
                    'align' => 'center',
                    'type' => 'bool',
                    'active' => 'status',
                ),
                'comment' => array(
                    'title' => $this->l('Comment'),
                    'align' => 'center',
                    'callback' => 'displayOrderLink' //will allow you to display the value in a custom way using a controller callback (see lower)
                )
            );
    
            parent::__construct();
        }
    
        public function renderList()
        {
            $this->addRowAction('edit');
            $this->addRowAction('delete');
            return parent::renderList();
        }
    
        public function displayOrderLink($comment)
        {
            switch($comment)
            {
                case 'value1':
                    return '<span style="color:red">mytext</span>';
                case 'value2':
                    return '<strong>mytext</strong>';
                default:
                    return 'defaultValue';
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-01
      • 1970-01-01
      • 2013-08-02
      相关资源
      最近更新 更多