Jump to content

Module - Ajouter une action custom sur l'AdminRequestSqlController


Recommended Posts

Bonjour à tous,

Actuellement sur la version 1.7.5.1 de PrestaShop, je cherche une solution quant à l'ajout d'une view pour une action custom ajoutée sur le controller AdminRequestSqlController à l'aide d'un module custom.

 

override/controllers/admin/AdminRequestSqlController.php

<?php

class AdminRequestSqlController extends AdminRequestSqlControllerCore {

    public function __construct() {
        parent::__construct();
    }

    public function renderList() {
        // Set toolbar options
        $this->display = null;
        $this->initToolbar();

        $this->displayWarning($this->trans('When saving the query, only the "SELECT" SQL statement is allowed.', array(), 'Admin.Advparameters.Notification'));
        $this->displayInformation('
		<strong>' . $this->trans('How do I create a new SQL query?', array(), 'Admin.Advparameters.Help') . '</strong><br />
		<ul>
			<li>' . $this->trans('Click "Add New".', array(), 'Admin.Advparameters.Help') . '</li>
			<li>' . $this->trans('Fill in the fields and click "Save".', array(), 'Admin.Advparameters.Help') . '</li>
			<li>' . $this->trans('You can then view the query results by clicking on the Edit action in the dropdown menu', array(), 'Admin.Advparameters.Help') . ' <i class="icon-pencil"></i></li>
			<li>' . $this->trans('You can also export the query results as a CSV file by clicking on the Export button', array(), 'Admin.Advparameters.Help') . ' <i class="icon-cloud-upload"></i></li>
		</ul>');

        $this->addRowAction('export');
        $this->addRowAction('customization');
        $this->addRowAction('view');
        $this->addRowAction('edit');
        $this->addRowAction('delete');

        return AdminController::renderList();
    }

    public function initProcess() {
        parent::initProcess();

        if (Tools::getValue('customization')) {
                $this->display = 'customization';
                $this->action = 'customization';
        }
    }

    public function initContent() {
        if ($this->display == 'customization') {
            $this->content .= $this->renderCustomization();
        }

        parent::initContent();
    }

    public function displayCustomizationLink($token, $id, $name = null) {
        $this->context->smarty->assign(array(
            'href' => self::$currentIndex.'&'.$this->identifier.'='.$id.'&customization='.$this->table.'&token='.($token != null ? $token : $this->token),
            'action' => $this->l('Customize')
        ));

        return $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/customrequestsql/views/templates/admin/list_action_customization.tpl');
    }

    public function renderCustomization() {
        return $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/customrequestsql/views/templates/admin/customization.tpl');
    }
}

Le problème est que ça n'affiche pas le template customization.tpl comme souhaité. Je souhaite que l'action redirige vers l'affichage du template customization.tpl, hors actuellement le template customization.tpl est affiché au dessus du template du controller.

Comment dois-je faire pour afficher uniquement le template customization.tpl quand l'action customization est sélectionnée ?

Merci d'avance.

 

template.png

requestsql.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...