Skip to content
MARICHAL Emmanuel edited this page Aug 2, 2017 · 4 revisions

PHP Code

$this->smarty->assign(array(
	'data' => Tools::jsonEncode(array(
		'columns' => array(
			array('content' => 'ID', 'key' => 'id', 'center' => true),
			array('content' => 'Email', 'key' => 'email'),
			array('content' => 'Name', 'key' => 'name'),
			array('content' => 'Active', 'key' => 'active', 'bool' => true, 'center' => true, 'fa' => true)
		),
		'rows' => array(
			array('id' => 1, 'email' => '[email protected]', 'name' => 'Bob'),
			array('id' => 2, 'email' => '[email protected]', 'name' => 'John')
		),
		'rows_actions' => array(
			array('title' => 'Edit', 'action' => 'edit_employee', 'icon' => 'pencil', 'img' => '../img/admin/edit.gif', 'fa' => 'pencil'),
			array('title' => 'Delete', 'action' => 'delete_employee', 'icon' => 'trash', 'img' => '../img/admin/delete.gif', 'fa' => 'trash')
		),
		'top_actions' => array(
			array('title' => 'Add employee', 'action' => 'add_employee', 'icon' => 'add', 'img' => 'themes/default/img/process-icon-new.png', 'fa' => 'plus'),
		),
		'url_params' => array('configure' => $this->name),
		'identifier' => 'id'
	))
));
  • The data variable must be json encoded
  • columns contains the table's columns:
    • content is the column's title
    • key is the index for the rows' array
    • center is optional and used to center the column's title
    • fa is optional and must be at true if you use font-awesome for your icons (only PS 1.5)
  • rows contains the tables's rows. Must be a key/value array.
  • rows_actions are buttons at the end of each rows
    • title is the button's name
    • action is the name of the action used on backend
    • icon is button's icon on PS 1.6.
    • img is button's image on PS 1.5 if you don't use fontawesome
    • fa is button's icon on PS 1.5 if you use fontawesome
  • top_actions are global action (like adding a new entry)
    • title is the button's name
    • action is the name of the action used on backend
    • icon is button's icon on PS 1.6.
    • img is button's image on PS 1.5 if you don't use fontawesome
    • fa is button's icon on PS 1.5 if you use fontawesome
  • url_params are additional params to add to each link. For example, the 'configure' params if you use PrestUI inside a module
  • identifier is the primary key of 'rows' to add to each link.

Remember to load Font-Awesome in your module if you want to use it with PrestUI!

HTML code

<ps-table header="{l s='Employees'}" icon="icon-users" content="{$data|replace:'{':'\{'|replace:'}':'\}'|escape:'htmlall':'UTF-8'}" no-items-text="{l s='No items found'}"></ps-table>
attribute optional value comment
header no text Table's title
icon yes class Table's icon. Only on 1.6.
content no json Table's data. Need to be escaped to be valid with PrestaShop's validator
no-items-text no Text Text if table is empty

Clone this wiki locally