prestashop 1.4移植家庭特色模块在一个新的钩子

时间:2012-07-15 16:23:05

标签: module prestashop transplant

我正试图将“divd”中列div之外的特色产品移到家中,如下所示:

<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'=&gt; 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中没有​​看到任何内容。

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

This module cannot be transplanted to this hook.

1 个答案:

答案 0 :(得分:0)

在评论中提供解决方案但我写了一个答案以防其他人需要它:

编辑模块的install()功能时,需要先卸载并重新安装