-1

我正在尝试将主页特色产品移到“newdiv”中的列 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' => 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.
4

1 回答 1

0

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

当你编辑install()一个模块的功能时,你需要卸载并重新安装它

于 2012-07-27T08:17:05.427 回答