zouhairHajji Posted April 22, 2015 Share Posted April 22, 2015 hello,i want create a new button on my moduledmincontroller and i don't know how i can implement a this script too.i create a code : $this->addRowAction('mybuttonAction'); and i create a methode : public function initProcess(){ parent::initProcess(); if (Tools::getValue('myButtonAction'.$this->table)){ $this->display = 'Modifier'; $this->action = 'Action'; } } please help me, i don't know how i'll add a script of button Link to comment Share on other sites More sharing options...
tuk66 Posted April 22, 2015 Share Posted April 22, 2015 What button? Can you post an screen shot? Link to comment Share on other sites More sharing options...
zouhairHajji Posted April 22, 2015 Author Share Posted April 22, 2015 in fact, i want to create a new button in my renderlist, and wen i'll wlick on it, i want that it charge a new template, thank you a lot Link to comment Share on other sites More sharing options...
electriz Posted April 22, 2015 Share Posted April 22, 2015 Hi, Check the url while you hover mouse over this button. There should be something like $deleteNAME&. In code you just have to check if it was submitted, and if so -> add your custom code if (Tools::isSubmit('deleteNAME')) { $this->html .= "your html"; return $this->html; } Link to comment Share on other sites More sharing options...
zouhairHajji Posted April 22, 2015 Author Share Posted April 22, 2015 i'll post all code that i had : <?php class AdminZouhair2Controller extends ModuleAdminController { public function __construct() { $this->tpl_folder = 'test_controller'; $this->bootstrap = true; $this->table = 'produit'; $this->className = 'produit'; //$this->content = 'html'; parent::__construct(); $this->context = Context::getContext(); } public function displayZouhairLink($token, $id){ $tpl = $this->createTemplate('list_action_zouhair.tpl'); $tpl->assign(array( 'href' => self::$currentIndex.'&token='.$this->token.'&'.$this->identifier.'='.$id.'&zouhair'.$this->table.'=1', 'action' => $this->l('Zouhairer') )); return $tpl->fetch(); } public function renderList(){ $this->addRowAction('zouhair'); $this->addRowAction('edit'); $this->addRowAction('delete'); // cette partit permet juste d'afficher les comumn // Building the list of records stored within the "test" table $this->fields_list = array( 'id_produit' => array( 'title' => $this->l('Identifiant'), 'align' => 'auto', 'width' => 25 ), 'designation' => array( 'title' => $this->l('Designation'), 'width' => 'auto' ), 'stock' => array( 'title' => $this->l('Stock'), 'width' => 'auto' ), 'datedernvte' => array( 'title' => $this->l('Date der vente'), 'width' => 'auto' ), 'contenance' => array( 'title' => $this->l('Contenance'), 'width' => 'auto' ), 'code_contenance' => array( 'title' => $this->l('Code contenance'), 'width' => 'auto' ), 'prixvente' => array( 'title' => $this->l('Prix'), 'width' => 'auto' ), 'datecreate' => array( 'title' => $this->l('Date Création'), 'width' => 'auto' ), 'datedrnmodif' => array( 'title' => $this->l('Date derniere modification'), 'width' => 'auto' ) ); /* // This adds a multiple deletion button $this->bulk_actions = array( 'delete' => array( 'text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?') ) ); */ parent::initToolbar(); return parent::renderList(); } /* // This method generates the Add/Edit form public function renderForm() { $this->fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Exemple 1 :'), 'image' => '../img/admin/cog.gif' ), 'input' => array( array( 'type' => 'text', 'lang' => true, 'label' => $this->l('Name:'), 'name' => 'id_produit', 'size' => 40 ), array( 'type' => 'file', 'label' => $this->l('Logo:'), 'name' => 'image', 'display_image' => true, 'desc' => $this->l('Upload Example image from your computer') ), array( 'type' => 'text', 'label' => $this->l('Designation 2:'), 'name' => 'designation', 'readonly' => true, 'disabled' => true, 'size' => 40 ) ), 'submit' => array( 'title' => $this->l('Enregistrer 3 :'), 'class' => 'button' ) ); return parent::renderForm(); } */ } and this is a screen : Link to comment Share on other sites More sharing options...
zouhairHajji Posted April 22, 2015 Author Share Posted April 22, 2015 and when i change the name of methode '' displayZouhairLink() '', exemple if i write displayZouhairenythingLink(){ // code} i get this page : Link to comment Share on other sites More sharing options...
zouhairHajji Posted April 22, 2015 Author Share Posted April 22, 2015 i tried your code, it shows me an empty page, i'll post a screen : Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now