Question

I've built my module and made an AdminController that list items from my table, with creation/update/delete/view.

In the listing page, I'd like to add a message after the breadcrumb, but before the table.

I saw there is a hook available : "displayAdminListBefore" and a block to extend "override_header", but I don't know how to make it work!

Can someone could point me in the right direction please?

Était-ce utile?

La solution

You can simply add your module to the displayAdminListBefore hook.

First hook the module to this hook with the install function:
public function install() { if (!parent::install() || !$this->registerHook('displayAdminListBefore')) return false; return true; }

Then create the hook function like that:
public function hookDisplayAdminListBefore($params) { return ' <div class="bootstrap"> <div class="alert alert-success"> <button data-dismiss="alert" class="close" type="button">×</button> Add your text here </div> </div> '; }

Or, you can also use a .tpl:

public function hookDisplayAdminListBefore($params) { $this->smarty->assign(array( 'first_var' => $first_var, 'second_var' => $second_var', )); return $this->display(__FILE__, 'views/templates/admin/listbefore.tpl'); }


The best way for you will be to override list_header.tpl and use the override_header hook.

To do so, create a new file list_header.tpl in modules/your_module/views/templates/admin/your_module/helpers/list/list_header.tpl

In this file copy the following code:
{extends file="helpers/list/list_header.tpl"} {block name="override_header"} Your text {$your_var} {/block}

$your_var must be defined in your controller in the function renderList():
$this->context->smarty->assign( array( 'your_var' => 'your_var_value' ) );

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top