如何将模块挂接到 prestashop 中的新页面?

发布于 2024-12-05 04:23:26 字数 403 浏览 0 评论 0原文

我尝试在 prestashop 中使用静态页面作为主页。我能想到的唯一方法是创建一个新页面(即shop.php),然后将当前在主页中挂钩的模型挂钩到新的shop.php。

我尝试遵循此 http://alvinjian。 blogspot.com/2011/01/prestashop-tips-how-to-create-complete.html 创建一个新页面,它确实可以显示静态文本,即“hello world” -但是我不知道将 homefeatured 模块(例如)连接到它。

你能以任何方式提供帮助吗?

谢谢

I am try to have a static page as the home page in prestashop. The only way I can think of dong this is by creating a new page (i.e. shop.php) then hook the models that are currently hooked in the home page to the new shop.php.

I tried to follow this http://alvinjiang.blogspot.com/2011/01/prestashop-tips-how-to-create-complete.html to create a new page, it does work up to the point of displaying static text i.e. "hello world" - however I don't know to hook the homefeatured module (for example) to it.

Can you help in any way?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往日情怀 2024-12-12 04:23:26

要将模块挂钩到新页面,您可以按照以下步骤操作:

在我的示例中,挂钩名为 topSearch

创建新挂钩

INSERT INTO `ps_hook` (`id_hook`, `name`, `title`, `description`, `position`) VALUES ("", "topSearch", "Top search block", "Description top search block", "1")

允许您的模块链接这个新的钩子

你只需要编辑你的 module.php 来添加一个用钩子命名的函数,例如:

public function hookTopSearch($params){
    global $smarty;
    $smarty->assign('test', 'it works !');
    return $this->display(__FILE__, 'viewfile.tpl');
}

然后将相应的模块链接到你的新钩子

Backoffice ->;模块->位置->嫁接模块

在.tpl文件中执行你的钩子

你已经创建了一个新的page.php,它包含include(dirname(_FILE_).'/ header.php'); 因此,通过在 override/classes/ 中创建一个名为 FrontController.php 的新文件来覆盖 FrontController.php。

然后将您的钩子添加到 displayHeader 函数

<?php
  class FrontController extends FrontControllerCore{
    public function displayHeader(){
    global $css_files, $js_files;

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

    // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
    header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');

    /* Hooks are volontary out the initialize array (need those variables already assigned) */
    self::$smarty->assign(array(
        'time' => time(),
        'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'),
        'static_token' => Tools::getToken(false),
        'token' => Tools::getToken(),
        'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'),
        'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'),
        'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,
        'content_only' => (int)Tools::getValue('content_only'),
        'exclude_page' => array('category','manufacturer')
    ));
    self::$smarty->assign(array(
        'HOOK_HEADER' => Module::hookExec('header'),
        'HOOK_TOP' => Module::hookExec('top'),
        'HOOK_TOP_SEARCH' => Module::hookExec('topSearch'),
        'HOOK_BUTTON_BRAND' => Module::hookExec('buttonBrand'),
        'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn')
    ));

    if ((Configuration::get('PS_CSS_THEME_CACHE') OR Configuration::get('PS_JS_THEME_CACHE')) AND is_writable(_PS_THEME_DIR_.'cache'))
    {
        // CSS compressor management
        if (Configuration::get('PS_CSS_THEME_CACHE'))
            Tools::cccCss();

        //JS compressor management
        if (Configuration::get('PS_JS_THEME_CACHE'))
            Tools::cccJs();
    }

    self::$smarty->assign('css_files', $css_files);
    self::$smarty->assign('js_files', array_unique($js_files));
    self::$smarty->display(_PS_THEME_DIR_.'header.tpl');
    }
  }

将相应的 smarty var 添加到您的模板文件中

{$HOOK_TOP_SEARCH}

To hook a module to a new page you can make follow this steps :

In my example the hook was named topSearch

Create a new hook

INSERT INTO `ps_hook` (`id_hook`, `name`, `title`, `description`, `position`) VALUES ("", "topSearch", "Top search block", "Description top search block", "1")

Allow your module to link with this new hook

You simply need to edit your module.php to add a function named with the hook, example :

public function hookTopSearch($params){
    global $smarty;
    $smarty->assign('test', 'it works !');
    return $this->display(__FILE__, 'viewfile.tpl');
}

Then link corresponded module to your new hook

Backoffice -> Module -> Position -> Grafting a module

Execute your hook in the .tpl file

You have create a new page.php, it contain include(dirname(_FILE_).'/header.php'); so override your FrontController.php by creating a new file named FrontController.php in override/classes/.

Then add your hook to the displayHeader function

<?php
  class FrontController extends FrontControllerCore{
    public function displayHeader(){
    global $css_files, $js_files;

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

    // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
    header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');

    /* Hooks are volontary out the initialize array (need those variables already assigned) */
    self::$smarty->assign(array(
        'time' => time(),
        'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'),
        'static_token' => Tools::getToken(false),
        'token' => Tools::getToken(),
        'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'),
        'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'),
        'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,
        'content_only' => (int)Tools::getValue('content_only'),
        'exclude_page' => array('category','manufacturer')
    ));
    self::$smarty->assign(array(
        'HOOK_HEADER' => Module::hookExec('header'),
        'HOOK_TOP' => Module::hookExec('top'),
        'HOOK_TOP_SEARCH' => Module::hookExec('topSearch'),
        'HOOK_BUTTON_BRAND' => Module::hookExec('buttonBrand'),
        'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn')
    ));

    if ((Configuration::get('PS_CSS_THEME_CACHE') OR Configuration::get('PS_JS_THEME_CACHE')) AND is_writable(_PS_THEME_DIR_.'cache'))
    {
        // CSS compressor management
        if (Configuration::get('PS_CSS_THEME_CACHE'))
            Tools::cccCss();

        //JS compressor management
        if (Configuration::get('PS_JS_THEME_CACHE'))
            Tools::cccJs();
    }

    self::$smarty->assign('css_files', $css_files);
    self::$smarty->assign('js_files', array_unique($js_files));
    self::$smarty->display(_PS_THEME_DIR_.'header.tpl');
    }
  }

To finish add the corresponded smarty var to your template file

{$HOOK_TOP_SEARCH}
兔小萌 2024-12-12 04:23:26

您可以在此处阅读如何在某个位置挂钩模块以及如何创建新挂钩。请注意,应为该特定挂钩安装该模块。

http://www.programmingtunes.com/creating-new-prestashop-hook/

You can read here that how you can hook a module at some place and also how you can create a new hook. Please note that the module should be installed for that particular hook.

http://www.programmingtunes.com/creating-new-prestashop-hook/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文