2016-09-14 2 views
1

私はPrestashopでカスタムモジュールを開発しています。そのモジュールでは、テーブルオーダーのようなカスタム保存された値を表示したいと思います。したがって基本的にテーブルにはヘッダー部分があり、そのヘッダー部分には対応するデータヘッダーのレコードを検索するためのフィールドが入力されます。モジュールのカスタムページヘッダーはこのリファレンスイメージのように表示されますenter image description herePrestashopカスタムモジュールadd table header

カスタムモジュールでこれを行う方法を教えてください。どんな助けや提案も本当に感知できるだろう。おかげ

+0

あなたのための私の解決策の仕事をしましたか? –

答えて

0

あなたがチェックofficial documentation

$helper->simple_header = false; 

、それをすべて動作させるためにいくつかの努力を必要としますが、テーブルのヘッダーを表示するための、そして私はあなたがHelperListクラスを使用している願っています。

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'; 
     } 
    } 
} 
関連する問題