如何在prestashop的自定义管理菜单页面中添加一个调用webservice的按钮

时间:2016-06-16 05:27:24

标签: php prestashop prestashop-1.6 prestashop-1.5

如何添加一个按钮和一个文本框,当我点击按钮时,它会调用prestashop的自定义管理菜单页面中的web服务,即我正在开发一个管理模块,我在其中创建了一个菜单,我能够显示网格与分页在该页面中的defalut prestashop网格,但我想在网格上方的按钮和文本框如何在prestashop 1.6中执行此操作。

这是我的控制器代码:

class QueryController extends ModuleAdminController
{

public $module;
public function __construct()
{
    $this->module = new querydr();     
    $this->addRowAction('view');
    //$this->removeButton('add'); //  this code to remove the add button
    $this->explicitSelect = false;
    $this->context = Context::getContext();
    $this->id_lang = $this->context->language->id;
    $this->lang = false;
    $this->ajax = 1;
    $this->path = _MODULE_DIR_.'querydr';
    $this->default_form_language = $this->context->language->id;
    $dormant_filter_days= Configuration::get('DORMANTUSERS_DORMANT_FILTER_DAYS');
    $this->table = 'query_dr';
    $this->className = 'QueryDr';
    $this->identifier = 'id_query_dr';
    $this->allow_export = true;
    $this->_select = " id_query_dr,order_no,ni_online_ref_id,transaction_type,response,status,error_code,error_msg,date_add,date_upd    
            ";
    $this->name = 'Query';
    //d( $this->select);
    $this->bootstrap = true;
    $this->fields_list = array(

    'id_query_dr' => array(
    'title' => $this->l('Id'),
    'align' => 'text-center',
    'remove_onclick' => true,
    'search' => false,
    ),

    'order_no' => array(
    'title' => $this->l('Order Number'),
    'align' => 'text-center',
    'remove_onclick' => true,
    //'search' => false,
    ),
    'ni_online_ref_id' => array(
    'title' => $this->l('Online Reference ID '),
    'align' => 'text-center',
    'remove_onclick' => true,
    //'search' => false,
    ),        
    'transaction_type' => array(
    'title' => $this->l('Transaction type'),
    'align' => 'text-center',
    'remove_onclick' => true
    ), 
     'status' => array(
    'title' => $this->l('Status'),
    'align' => 'text-center',
    'remove_onclick' => true
    ),  
             'error_code' => array(
    'title' => $this->l('Error Code'),
    'align' => 'text-center',
    'remove_onclick' => true
    ), 
             'error_msg' => array(
    'title' => $this->l('Error Message'),
    'align' => 'text-center',
    'remove_onclick' => true
    ), 
             'date_add' => array(
    'title' => $this->l('Date Added'),
    'align' => 'text-center',
    'remove_onclick' => true
    ), 
             'date_upd' => array(
    'title' => $this->l('date_upd'),
    'align' => 'text-center',
    'remove_onclick' => true
    ),     
    );


    parent::__construct();
}




public function initPageHeaderToolbar()
{
    $this->page_header_toolbar_title = $this->l('Query Dr Logs');
    parent::initPageHeaderToolbar();
}

public function initToolbar()
{
    parent::initToolbar();
    $this->context->smarty->assign('toolbar_scroll', 1);
    $this->context->smarty->assign('show_toolbar', 1);
    $this->context->smarty->assign('toolbar_btn', $this->toolbar_btn);
}

}

1 个答案:

答案 0 :(得分:0)

您需要覆盖initContent()方法。 示例:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="search" id="prodinput" value="peanuts" />
<div class="support-product">
  <ul class="browse-products">
    <li><a href="#">jam</a></li>
    <li><a href="#">elephants</a></li>
    <li><a href="#">peanuts</a></li>
  </ul>
</div>

您的表单渲染:

/**
  * @see AdminController::initContent
  */
public function initContent()
{
 $this->getLanguages();
 $this->initToolbar();
 $this->initTabModuleList();
 $this->initPageHeaderToolbar();
 $this->content .= $this->renderModulesList();
 $this->content .= $this->renderKpis();
 $this->content .= $this->renderMyCustomFormList();
 $this->content .= $this->renderList();
 $this->content .= $this->renderStats();
 $this->content .= $this->renderOptions();
 $this->context->smarty->assign(array(
                'page_header_toolbar_btn' => $this->page_header_toolbar_btn,
                    'show_page_header_toolbar' => $this->show_page_header_toolbar,
                    'page_header_toolbar_title' => $this->page_header_toolbar_title,
                    'title' => $this->page_header_toolbar_title,
                    'toolbar_btn' => $this->page_header_toolbar_btn,

                'content' => $this->content,
                'lite_display' => $this->lite_display,
                'url_post' => self::$currentIndex . '&token=' . $this->token
  ));
}