Jump to content

Création a buton action


zouhairHajji
 Share

Recommended Posts

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

Share this post


Link to post
Share on other sites

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;
}

Share this post


Link to post
Share on other sites

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 : 
post-985269-0-05108300-1429699200_thumb.jpg

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More