module - 在新的钩子中,prestashop 1.4移植家庭特色模块

  显示原文与译文双语对照的内容
0 0

我正在尝试在"newdiv"中的列div之外的columns中移动featured产品,如下所示:


<header>
 hook header
</header> 
<container>
 <div central_column>
. 
 <!-- here is the featured products block -->
. 
 </div>
 <div right_column>
 hook right column
 </div>
</container>

<newdiv><--! here where i want to show featured products --></newdiv>

<footer>
 hook footer
</footer>

为此,我编辑了 FrontController.php,添加了显示页脚('hook_featured_home'=> Module::hookExec('homeFeatured') )的钩子:


public function displayFooter()
 {

 if (!self::$initialized)
 $this->init();

 self::$smarty->assign(array(
 'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => self::$cart)),
 'HOOK_FEATURED_HOME' => Module::hookExec('homeFeatured'),
 'HOOK_FOOTER' => Module::hookExec('footer'),
 'content_only' => (int)(Tools::getValue('content_only'))));
 self::$smarty->display(_PS_THEME_DIR_.'footer.tpl');
//live edit
 if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
 {
 self::$smarty->assign(array('ad' => $ad, 'live_edit' => true));
 self::$smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
 }
 else
 Tools::displayError();
}

在文件 footer.tpl 上,我添加了钩子:


 <!-- featured products -->
 {if $page_name == 'index'}
 <div id="homeFeatured">
 {$HOOK_FEATURED_HOME}
 </div>
 {/if}

我在数据库中添加了


id name title descritption position live_edit

97 homeFeatured Home Featured Products NULL 0 0

在 module/homefeatured/homefeatured.php 中,我添加了:


function install()
 {
 if (!Configuration::updateValue('HOME_FEATURED_NBR', 8) OR!parent::install() OR!$this->registerHook('home') OR!$this->registerHook('homeFeatured'))
 return false;
 return true;
 }

在课堂的最后


function homeFeatured($params)
 {
//return $this->hookHome($params);
 echo 'hook test';

 }

我在 div newdiv没有看到任何东西。

当我尝试将模块移植到后面 Office 中的新钩子时,我收到:


This module cannot be transplanted to this hook.

时间: 原作者:

0 0

给出了一个注释,但我写了一个答案,以防别人需要它:

当你编辑模块的install() 函数时,你需要卸载它并在

原作者:
...