Prestashop自定义模块添加表头

时间:2016-09-14 06:18:40

标签: prestashop prestashop-1.6

我正在Prestashop中开发一个自定义模块。在该模块中,我想显示我的自定义保存值,如表顺序。所以基本上该表应该有标题部分,在该标题部分中将有输入字段来搜索相应数据标题的记录。因此,模块自定义页面标题应该显示为此参考图像enter image description here

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

2 个答案:

答案 0 :(得分:0)

你需要付出一些努力才能使它全部工作,但显示表头,我希望你使用HelperList类,

$helper->simple_header = false;

检查official documentation

答案 1 :(得分:0)

假设你知道如何制作一个模块,你需要的只是这个(请记住它是一个例子,你必须在这里和那里更换点点滴滴。)

档案/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';
        }
    }
}
相关问题