我的模块没有显示在前端,我正在关注此链接doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module在prestashop 1.6中创建自定义模块。我检查了位置,清除并禁用缓存,卸载并重新安装模块但到目前为止没有任何工作。 p.s config.xml是自动生成的。
这是我的mymodule.php代码
<?php
if (!defined('_PS_VERSION_'))
exit;
class MyModule extends Module
{
public function __construct()
{
$this->name= 'mymodule';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'Zeeshan Abbas';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.5','max' => '1.6');
$this->dependencies = array('blockcart');
parent::__construct();
//it is not 1 it is L ok
$this->displayName = $this->l('My module');
$this->description = $this->l('Description of my module');
$this->confirmUninstall = $this->l('are you sure you want to uninstall?? ');
if (!Configuration::get('MYMODULE_NAME'))
$this->warning = $this->l('No name provided');
}
public function install() {
if (Shop::isFeatureActive())
Shop::setContext(Shop::CONTEXT_ALL);
return parent::install() &&
$this->registerHook('leftColumn') &&
$this->registerHook('header') &&
Configuration::updateValue('MYMODULE_NAME','my friend');
}
public function uninstall()
{
if (!parent::uninstall() ||
!Configuration::deleteByName('MYMODULE_NAME'))
return false;
return true;
}
/*public function install()
{
if (parent::install() == false)
return false;
return true;
}*/
}
?>
这是我的mymodule.tpl
<!-- Block mymodule -->
<div id="mymodule_block_left" class="block">
<h4>Welcome!</h4>
<div class="block_content">
<p>Hello,
{if isset($my_module_name) && $my_module_name}
{$my_module_name}
{else}
World
{/if}
!
</p>
<ul>
<li><a href="{$my_module_link}" title="Click this link">Click me!</a></li>
</ul>
</div>
</div>
<!-- /Block mymodule -->
答案 0 :(得分:4)
缺少hookDisplayHeader
和hookLeftColumn
方法。
public function hookDisplayLeftColumn($params)
{
$this->context->smarty->assign(
array(
'my_module_name' => Configuration::get('MYMODULE_NAME'),
'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display')
)
);
return $this->display(__FILE__, 'mymodule.tpl');
}
public function hookDisplayHeader()
{
$this->context->controller->addCSS($this->_path.'css/mymodule.css', 'all');
}