Prestashop自定义模块添加表格标题

Prestashop自定义模块添加表格标题,prestashop,prestashop-1.6,Prestashop,Prestashop 1.6,我正在Prestashop中开发一个自定义模块。在该模块中,我希望显示自定义保存的值,如表顺序。因此,表基本上应该有标题部分,在标题部分有输入字段来搜索记录中相应的数据标题。因此,模块自定义页面标题应显示如下参考图像 那么,有人能告诉我如何在自定义模块中实现这一点吗?任何帮助和建议都是非常值得的。谢谢除了显示表头之外,您还需要一些努力才能使其正常工作,我希望您使用的是HelperList类 $helper->simple_header = false; 检查。除了显示表头之外,您还需要一

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


那么,有人能告诉我如何在自定义模块中实现这一点吗?任何帮助和建议都是非常值得的。谢谢

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

$helper->simple_header = false;

检查。

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

$helper->simple_header = false;

检查。

假设您知道如何制作一个模块,那么您所需要的就是这个(请记住,这是一个示例,您必须到处替换位和块)

文件
/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';
        }
    }
}
类AdminRulesController扩展了ModuleAdminController
{
公共函数构造()
{
$this->module='mymodule';
$this->table='rules';//为列表查询的表
$this->className='Rules';//列表项的类
$this->lang=false;
$this->bootstrap=true;
$this->context=context::getContext();
$this->fields\u list=数组(
“id_规则”=>数组(
'title'=>this->l('ID'),
“对齐”=>“居中”,
'类'=>'固定宽度xs',
'search'=>false,//如果希望某些字段不可搜索/排序
'orderby'=>false,
),
'name'=>数组(
'title'=>$this->l('Rule name'),
“对齐”=>“居中”,
),
“是否处于活动状态”=>数组(
'title'=>$this->l('Active'),
“对齐”=>“居中”,
'type'=>'bool',
“活动”=>“状态”,
),
'注释'=>数组(
'title'=>this->l('Comment'),
“对齐”=>“居中”,
'callback'=>'displayOrderLink'//将允许您使用控制器回调以自定义方式显示该值(请参见下文)
)
);
父项::_构造();
}
公共函数renderList()
{
$this->addRowAction('edit');
$this->addRowAction('delete');
返回父级::renderList();
}
公共函数displayOrderLink($comment)
{
切换($comment)
{
案例“value1”:
返回“mytext”;
案例“价值2”:
返回“mytext”;
违约:
返回“defaultValue”;
}
}
}

假设您知道如何制作一个模块,那么您所需要的就是这个(请记住,这是一个示例,您必须在这里和那里替换位和块)

文件
/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';
        }
    }
}
类AdminRulesController扩展了ModuleAdminController
{
公共函数构造()
{
$this->module='mymodule';
$this->table='rules';//为列表查询的表
$this->className='Rules';//列表项的类
$this->lang=false;
$this->bootstrap=true;
$this->context=context::getContext();
$this->fields\u list=数组(
“id_规则”=>数组(
'title'=>this->l('ID'),
“对齐”=>“居中”,
'类'=>'固定宽度xs',
'search'=>false,//如果希望某些字段不可搜索/排序
'orderby'=>false,
),
'name'=>数组(
'title'=>$this->l('Rule name'),
“对齐”=>“居中”,
),
“是否处于活动状态”=>数组(
'title'=>$this->l('Active'),
“对齐”=>“居中”,
'type'=>'bool',
“活动”=>“状态”,
),
'注释'=>数组(
'title'=>this->l('Comment'),
“对齐”=>“居中”,
'callback'=>'displayOrderLink'//将允许您使用控制器回调以自定义方式显示该值(请参见下文)
)
);
父项::_构造();
}
公共函数renderList()
{
$this->addRowAction('edit');
$this->addRowAction('delete');
返回父级::renderList();
}
公共函数displayOrderLink($comment)
{
切换($comment)
{
案例“value1”:
返回“mytext”;
案例“价值2”:
返回“mytext”;
违约:
返回“defaultValue”;
}
}
}

我的解决方案对您有效吗?我的解决方案对您有效吗?