Jump to content

how to setup a "detail" action for helper view ?


jemmeli

Recommended Posts

hello

 

I am wondering how to set up an detail action in back-office for helper view I have already create a controller that extend from "ModuleAdminController" and have all the functions needed like renderList, ajaxProcessDetails, renderForm and also I search about this topic in documentation of prestashop 1.5 and I did some google search i succed to show the button but when I click it nothing happen it normally expand another list but it didin't do that, I just want to know what's wrong please.

 

the button "details " generated by the views helper in the controller admin is cercled by the red stroke in the following image :

 

details_button.jpg

 

this is my controller for back-office:

 


<?php

/*
* the admin controller
*/

class AdminBlockPersoController extends ModuleAdminController {

public function __construct() {

	$this->table = 'blockpersoadmintexture';
	$this->className = 'BlockPerso';
	$this->lang = false;

	//$product = new Product($this->id_product);

	//View Helpers dans le constructeur
	$this->fields_list = array(
		'id_blockpersoadmintexture' => array(
			'title' => '#'
		),
		'id_product' => array(
			'title' => 'id_produit'
		),
		'reference' => array(
			'title' => 'Réf'
		),
		'nom' => array(
			'title' => 'Nom'
		),
		'description' => array(
			'title' => 'Description'
		)
	); /* end of fields_list */


	// This adds a multiple deletion button
	$this->bulk_actions = array(
		'delete' => array(
			'text' => $this->l('Delete selected'),
			'confirm' => $this->l('Delete selected items?')
		)
	);


	//for the image treatment
	$this->fieldImageSettings = array(
		'name' => 'yyy',
		'dir' => 'texture'
	);

	//echo _PS_MODULE_DIR_.'blockpersoadmin/pattern';
	/*
	this in postprocess
	$this->postImage($new_carrier->id);*/


	parent::__construct();

	//$this->actions = array('delete');
}

// This method generates the list of results
public function renderList() {
	// Adds an Edit button for each result
	$this->addRowAction('edit');

	// Adds a Delete button for each result
	$this->addRowAction('delete');

	// Adds a Delete button for each result
	$this->addRowAction('details');

	return parent::renderList();
}


/**
 * method call when ajax request is made with the details row action
 * @see AdminController::postProcess()
 */
public function ajaxProcessDetails() {
	if (($id = Tools::getValue('id'))) {
		// override attributes
		$this->display = 'list';
		$this->lang = false;
		$this->addRowAction('edit');
		$this->addRowAction('delete');
		$this->_select = '* FROM ps_blockpersoadmintexture';

		// get list and force no limit clause in the request
		$this->getList($this->context->language->id);
		// Render list
		$helper = new HelperList();
		$helper->actions = $this->actions;
		$helper->list_skip_actions = $this->list_skip_actions;
		$helper->no_link = true;
		$helper->shopLinkType = '';
		$helper->identifier = $this->identifier;
		$helper->imageType = $this->imageType;
		$helper->toolbar_scroll = false;
		$helper->show_toolbar = false;
		//$helper->orderBy = 'position';
		//$helper->orderWay = 'ASC';
		$helper->currentIndex = self::$currentIndex;
		$helper->token = $this->token;
		$helper->table = $this->table;
		$helper->position_identifier = $this->position_identifier;
		// Force render - no filter, form, js, sorting ...
		$helper->simple_header = true;
		$content = $helper->generateList($this->_list, $this->fields_list);

		echo Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content));

	}
	die;
}


// This method generates the Add/Edit form
public function renderForm() {
	// Building the Add/Edit form
	$this->fields_form = array(
		'legend' => array(
			'title' => $this->l('Test')
		),
		'input' => array(
			array(
				'type' => 'select',
				'label' => $this->l('product'),
				'name' => 'id_product',
				'required' => true,
				'desc' => $this->l('nom du produit associé'),
				'options' => array(
					'query' => Product::getProducts(1, 1, 1000, "id_product", "DESC"),
					'id' => 'id_product',
					'name' => 'name',
					'value' => 'id_product'
				)
			),





			array(
				'type' => 'text',
				'label' => $this->l('Réference:'),
				'name' => 'reference',
				'size' => 33,
				'required' => true,
				'desc' => $this->l('le référence'),
			),



			 array(
				'type' => 'text',
				'label' => $this->l('Nom:'),
				'name' => 'nom',
				'size' => 33,
				'required' => true,
				'desc' => $this->l('le nom'),
			),

			array(
				'type' => 'text',
				'label' => $this->l('Description:'),
				'name' => 'description',
				'size' => 33,
				'required' => true,
				'desc' => $this->l('la Description'),
			),



			 array(
				'type' => 'file',
				'label' => $this->l('Texture :'),
				'name' => 'yyy',
				'desc' => $this->l('Upload a texture from your computer .gif, .jpg, .jpeg .png')
			)




		),
		'submit' => array(
			'title' => $this->l('	Save   '),
			'class' => 'button'
		)
	);

	return parent::renderForm();
}

}



Edited by jemmeli (see edit history)
Link to comment
Share on other sites

  • 1 year later...

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...