我正在開發Prestashop自定義模塊。在該模塊中,我想顯示自定義保存的值,如表格順序。所以基本上表應該有標題部分,並在該標題部分將輸入字段來搜索相應的數據標題的記錄。所以模塊自定義頁面標題應顯示像這樣的參考圖像Prestashop自定義模塊添加表格標題
所以有人可以告訴我如何在自定義模塊中做到這一點?任何幫助和建議都將非常可觀。由於
我正在開發Prestashop自定義模塊。在該模塊中,我想顯示自定義保存的值,如表格順序。所以基本上表應該有標題部分,並在該標題部分將輸入字段來搜索相應的數據標題的記錄。所以模塊自定義頁面標題應顯示像這樣的參考圖像Prestashop自定義模塊添加表格標題
所以有人可以告訴我如何在自定義模塊中做到這一點?任何幫助和建議都將非常可觀。由於
假設你知道如何製作一個模塊,你所需要的只是這個(記住它是一個例子,你必須在這裏和那裏替換零件)。
文件/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';
}
}
}
難道我的解決方案爲您工作? –