Создание модуля Prestashop - админка
2012-12-26
Если нужно добавить некоторый функционал в админку модуля, то нужно в файл модуля добавить функцию public function getContent().
Примеры.
Можно взять любой простой модуль, у которого есть конфигурируемая админка, подойдет Block Contact. Как видно, у него есть своя админка.

В которой есть настройки.

Теперь смотрим где они находятся в коде.
if (!defined('_PS_VERSION_'))
exit;
class Blockexport extends Module
{
public function __construct()
{
$this->name = 'blockexport';
$this->tab = 'other';
$this->version = '1.0';
$this->author = 'khtulhu';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('blockexport');
$this->description = $this->l('Export xml file');
}
public function install()
{
if (!parent::install())
return false;
return true;
}
public function uninstall()
{
return parent::uninstall();
}
public function getContent()
{
$output = ''.$this->displayName.'
';
$output = '';
return $output;
}
}
Редактируя код в этой функции, можно менять функциональность админки своего модуля.
Вставляем этот кусок кода в свой модуль.
И смотрим в админке.

Теперь можно вставить внутрь функции например кнопку для запуска "чего-то".
public function getContent()
{
$html .= '
<h2>'.$this->displayName.'</h2>
<form action="changestate.php" method="post">
<fieldset>
<input type="submit" name="submitModule" value="Generate" class="button" /></center>
</fieldset>
';
return $html;
}
Вот что вышло.
