Я создал файл mymodule.php для Prestashop 1.4Prestashop базовый модуль, небольшой корректировки
<?php
if (!defined('_CAN_LOAD_FILES_'))
exit;
class MyModule extends Module
{
function __construct()
{
$this->name = "mymodule";
$this->version = "1.0";
$this->author = "Tomtop";
$this->tab = "front_office_features";
$this->_postErrors = array();
parent::__construct();
$this->displayName = $this->l("My Module Name");
$this->description = $this->l("This is my module description.");
}
protected function setConfig($key,$value)
{
return Configuration::updateValue($this->name.$key,$value,true);
}
protected function getConfig($value)
{
return Configuration::get($this->name.$value);
}
protected function deleteConfig($value)
{
return Configuration::deleteByName($this->name.$value);
}
function install()
{
if (!parent::install()
OR !$this->registerHook('home')
OR !$this->registerHook('footer')
)
return false;
return true;
}
public function uninstall()
{
parent::uninstall();
return true;
}
public function hookHome($params)
{
}
public function hookfooter($params)
{
}
private function _postProcess()
{
$this->_html .= '<div class="conf confirm">'.$this->l("Updated")."</div>";
}
public function getContent()
{
$this->_html .= "<h2>".$this->displayName."</h2>";
if (Tools::isSubmit("submit"))
{
$this->_postProcess();
}
$this->_displayForm();
return $this->_html;
}
private function _displayForm()
{
$this->_html .= '<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<fieldset>
<legend><img src="../modules/scroller/logo.gif" alt="" class="middle" />'.$this->l('Settings').'</legend>
<br />
<center><input type="submit" name="submit" value="'.$this->l('Upgrade').'" class="button" /></center>
</fieldset>
</form>';
}
}
Где в коде выше следует добавить шаблон mymodule.tpl, которые содержат основной HTML-код, т.е.
return $this->display(__FILE__, 'mymodule.tpl');
Кроме того, в каком месте в mymodule.php добавить JS и CSS файлы, которые связаны в головной метке, как это:
public function hookHeader()
{
Tools::addJS($this->_path.'js/myjscript1.js');
Tools::addJS($this->_path.'js/myjscript2.js');
Tools::addCSS($this->_path.'css/mymodule.css', 'all');
}
И где следует добавить global $smarty;
, если это необходимо в приведенном выше коде?
Крючки не обязательно связаны с визуальным где вы хотите показывать контент. Они используются во многих ситуациях, например, при вызове любого продукта будет вызываться воображаемый 'hookProductUpdate', чтобы вы могли отправлять сообщения электронной почты клиентам, говоря:« Вау цены были изменены для продукта X ». –
Я думаю, что «встраиваемые решения» - это плохой способ узнать. Понять и сделать это самим лучше. Если у вас над головой, вы должны изучать основы, которые не погружаются в глубокий конец, и если это не так, вы можете понять и сделать это самостоятельно. –