Jump to content

intégrer le bloc Publicité dans RightColumProduct


Recommended Posts

Bonjour,

J'aimerais intégrer le bloc Publicité dans la fiche produit, sous l'encart de panier de la page,

cf mon site en cours : http://www.traduction-assermentee-officielle.com/index.php?id_product=8&controller=product

Or il ne peut être intégrer que ds LeftColumn et RigthColumn, que je n'ai pas sur mon site.

Je n'arrive pas à modifier blockadvertising.php pour autoriser de greffer le module sur RightColumnProduct.

Quelqu'un peut-il m'aider ?

Merci!!

Link to comment
Share on other sites

J'ai pas ce module, donc j'ai pas le code sous la main, mais t'as cherché des déclarations de type $this->registerHook('rightColumn') dans la méthode install() ? Normalement tu ajoutes une déclaration similaire avec le nom de ton hook, et tu penses aussi à copier ( et adapter pour rightColumnProduct ) la fonction qui doit s'appeler hookRightColumn() probablement située en fin de fichier et tout se passe bien :)

Link to comment
Share on other sites

Pour le bloc advertising, public function install() est ainsi :

 

public function install()
    {
        if (!parent::install())
            return false;

        // Hook the module either on the left or right column
        $theme = new Theme(Context::getContext()->shop->id_theme);
        if ((!$theme->default_left_column || !$this->registerHook('leftColumn'))
            && (!$theme->default_right_column || !$this->registerHook('rightColumn'))
        )
        {
            // If there are no colums implemented by the template, throw an error and uninstall the module
            $this->_errors[] = $this->l('This module needs to be hooked to a column, but your theme does not implement one');
            parent::uninstall();

            return false;
        }

        Configuration::updateGlobalValue('BLOCKADVERT_LINK', 'http://www.prestashop.com/');
        Configuration::updateGlobalValue('BLOCKADVERT_TITLE', 'PrestaShop');
        // Try to update with the extension of the image that exists in the module directory
        foreach (scandir(_PS_MODULE_DIR_.$this->name) as $file)
            if (in_array($file, array('advertising.jpg', 'advertising.gif', 'advertising.png')))
                Configuration::updateGlobalValue('BLOCKADVERT_IMG_EXT', substr($file, strrpos($file, '.') + 1));

        return true;
    }

 

donc j'ai essayé ceci :

     if ((!$theme->default_left_column || !$this->registerHook('leftColumn'))
            && (!$theme->default_right_column || !$this->registerHook('RightColumnProduct'))

 

mais cela ne fonctionne pas,

j'ai pourtant demandé un left et right colums ds Themes/preference, même si j'ai degreffé tous les modules sur ces 2 hook pour ne pas avoir de colonnes justement..

 

ce qu'il faudrait, c'est sans doute modifier le code :   // If there are no colums implemented by the template, throw an error and uninstall the module
            $this->_errors[] = $this->l('This module needs to be hooked to a column, but your theme does not implement one');
            parent::uninstall();

pour dire que quand il n'y a pas de columns, le module soit installé dans RightColumnProduct, mais je ne sais pas comment faire ça..

 

Avez vous une idée ?

merci

Link to comment
Share on other sites

Quand vous dites cela ne fonctionne pas, c'est à dire que vous ne pouvez pas le greffer, c'est bien ça ?

 

En fait vous avez bien compris que vous vérifiez l'existence des colonnes droite et gauche. Vous ne rentrez pas dans le "If there are no columns" puisque vous en avez, nul besoin de modifier le code du coup.

A tout hasard, avec 

$this->registerHook('RightColumnProduct');

placé juste avant 

if ((!$theme->default_left_column || !$this->registerHook('leftColumn'))
            && (!$theme->default_right_column || !$this->registerHook('rightColumn'))

ça ne fonctionne pas ?

Edited by Xuân (see edit history)
Link to comment
Share on other sites

J'ai essayé 2 choses à l'instant:

ceci :

 

public function install()
    {
        if (!parent::install())
            return false;

        // Hook the module either on the left or right column
        $theme = new Theme(Context::getContext()->shop->id_theme);
        $this->registerHook('RightColumnProduct')
        if ((!$theme->default_left_column || !$this->registerHook('leftColumn'))
            && (!$theme->default_right_column || !$this->registerHook('rightColumn'))
        )
        {
            // If there are no colums implemented by the template, throw an error and uninstall the module.....

 

Cela bloque complétement l'accès au backOffice car cela crée une erreur, dès que je note  $this->registerHook('RightColumnProduct')

 

et autre chose, ceci :

    public function install()
    {
        if (!parent::install())
            return false;

        // Hook the module either on the left or right column
        $theme = new Theme(Context::getContext()->shop->id_theme);
        
        if ((!$theme->default_left_column || !$this->registerHook('RightColumnProduct'))
            && (!$theme->default_right_column || $this->registerHook('RightColumnProduct'))
        )
        {
            // If there are no colums implemented by the template, throw an error and uninstall the module
            $this->_errors[] = $this->l('This module needs to be hooked to a column, but your theme does not implement one');
            parent::uninstall();

            return false;
        }

 

Dans ce cas, quand j'essaie de greffer le module BlockAdvertising sur RightColumnProduct, cela me dit que ce module ne peut pas être greffé sur ce hook.

 

C'est bizarre que l'on ne puisse pas le greffer ailleurs que sur les colonnes.

Cela doit bien être possible, mais ça a l'air compliqué tout de même..

Link to comment
Share on other sites

"cela crée une erreur, dès que je note  $this->registerHook('RightColumnProduct') "

 

J'avais fait exprès d'éditer, faut pas oublier le point virgule à la fin :P

Avec le code ci dessous, ça donne quoi ?

 $this->registerHook('RightColumnProduct');

Edit : et d'ailleurs, pouvez vous mettre votre boutique en mode debug pour avoir les erreurs du type oubli de point virgule SVP ? Je vous laisse chercher vite fait comment faire, je suis sur mobile et j'ai plus la manip en tête...

Edited by Xuân (see edit history)
Link to comment
Share on other sites

En effet..je viens de réessayer avec le ';' à la fin, je n'ai donc plus d'erreur de code, mais cela ne fonctionne toujours pas, cela continue de dire 'Ce module ne peut être greffé à ce hook' quand je tente de Greffer blockAdvertising sur RightColumnProduct.

J'ai essayé le mode debug, apparemment cela n'indique rien sur ce pb..il y avait 4 erreurs, 2 fois a248.e.akamai.net:serveur does not support RFC 5746, see CVE-2009-3555 et Error: permission denied to access property 'toString'

incompréhensible pour moi..

Donc en attendant mieux, j'ai finalement modifié l'image payment-logo.png de productpaymentlogos, en rajoutant mon image de Pub dans cette nouvelle image de payment-logo..mais ce n'est pas l'idéal, surtout si il y a du multilingue..

Merci tout de même pour votre aide!

Link to comment
Share on other sites

Salut,

 

En fait, il faut seulement ajouter la fonction qui va bien  ^_^  :

    public function hookDisplayRightColumnProduct($params)
    {
        return $this->hookRightColumn($params);
    }

Ce qui est dit plus haut est bon (Avec le mot display en plus: $this->registerHook('displayRightColumnProduct') ) mais seulement si tu veux le greffer à l'installation.

 

Avec ce bout de code, tu pourras le greffer en passant par le menu "Greffer un module"
 

Edited by anteverce (see edit history)
Link to comment
Share on other sites

Bonjour,

Merci en effet, ce code fonctionne! J'ai appris quelquechose!

Alors par contre, je me suis trompée..en fait, je pensais qu'en demandant de greffer sur le RightColumnProduct, cela s'afficherait sous le bloc panier à droite, or apparemment le RightColumnProduct, c'est la partie texte descriptif à droite de la photo du produit. Du coup, en effet, l'encart de pub s'affiche bien sous cette partie, sous mon bouton Envoyer vos fichiers.

http://www.traduction-assermentee-officielle.com/index.php?id_product=8&controller=product

Ce que je cherche, c'est afficher le block Pub sous le bloc panier de droite. Donc actuellement j'ai modifié l'image des logis de paiement en y intégrant l'encart de pub, mais j'aimerais réussir à intégrer ce bloc Pub en dehors du bloc Panier, juste dessous.

Si je demande de greffer dans Right columns, cela crée une 3eme micro colonne à droite de la page avec la Pub et le bloc Panier est tout rétréci.

Donc, quelqu'un sait-il comment s'appelle ce hook qui  contient le bloc panier ?? ou comment faire ?

Merci à tous pour votre aide

Link to comment
Share on other sites

Donc remplace :

    public function hookDisplayRightColumnProduct($params)
    {
        return $this->hookRightColumn($params);
    }

par :

    public function hookDisplayProductButtons($params)
    {
        return $this->hookRightColumn($params);
    }

Tu auras ton bloc logopayment et juste en dessous ton blocpub

Link to comment
Share on other sites

Merci  pour cette réponse si rapide.

Je viens d'essayer, et voici le résultat : http://www.traduction-assermentee-officielle.com/index.php?id_product=8&controller=product

En fait, le bloc pub s’intègre dans le bloc de paiement du coup, et j'aimerais qu'il soit dessous, sans agrandir le bloc de paiement, je ne sais pas si c'est très clair..

Désolée d'être pénible pour ça..

En fait, pour essayer de comprendre la fonction, comment cela fonctionne-t-il ?

on note public function suivi du hook qui doit recevoir le module, et dessous dans return, on indique quoi ? pourquoi c'est hookRightColumn ? parce que le module de paiement dépend de RightColumn ? je ne comprends pas le principe..

En tous cas, merci pour ton aide

Link to comment
Share on other sites

Explication :

 

Public function suivi du hook qui doit recevoir le module

C'est tout a fait ça.

 

Pourquoi c'est hookRightColumn ?

Parce qu'on affiche exactement la meme chose que ce qu'il y a dans RightColumn

 

Bon alors pour afficher ton blocpub en dehors du cadre "ajouter au panier" ET en dessous il te faut un hook perso

 

Donc tu peux mettre ça :

    public function hookDisplayUnderProductButtons($params)
    {
        return $this->hookRightColumn($params);
    }

Du coup, il faut ajouter ça dans la fonction install(): (Juste en dessous de $theme = ...)

!$this->registerHook('displayUnderProductButtons');

Et dans product.tpl juste après :

                        {if isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS}{$HOOK_PRODUCT_ACTIONS}{/if}
                        
                    </div> <!-- end box-cart-bottom -->
                </div> <!-- end box-info-product -->

tu ajoutes ton hook perso :

{hook h='displayUnderProductButtons'}

Voila normalement tu réinitialises ton module et c'est bon :)

 

J'espère que c'est assez clair ^^

 

  • Like 1
Link to comment
Share on other sites

 et tu penses aussi à copier ( et adapter pour rightColumnProduct ) la fonction qui doit s'appeler hookRightColumn() probablement située en fin de fichier et tout se passe bien :)

J'avais oublié de la détailler, mea culpa ^^

 

Par contre anteverce. Ta description de la création d'un hook perso est juste parfaite. Impossible de savoir ou on était obligé de mettre des display avant ^^ Donc j'arrivais pas à faire le mien, maintenant si. Merci beaucoup beaucoup. 

Edited by Xuân (see edit history)
  • Like 1
Link to comment
Share on other sites

Alors..pour l'instant je ne vois pas apparaitre le nouveau hook..

Voilà ce que j'ai fait :

dans blockadvertising.php :

j'ai rajouté ce code:

 

/*rajout de code pour permettre de greffer ce module sous le bloc panier*/
    public function hookDisplayUnderProductButtons($params)
    {
        return $this->hookRightColumn($params);
    }
    /**/
    public function install()
    {
        if (!parent::install())
            return false;

        // Hook the module either on the left or right column
        $theme = new Theme(Context::getContext()->shop->id_theme);
        /*rajout pour intégrer le block pub sous le bloc panier, dans le nouveau hook crée*/
        !$this->registerHook('displayUnderProductButtons');
        /**/
        if ((!$theme->default_left_column || !$this->registerHook('leftColumn'))
            && (!$theme->default_right_column || !$this->registerHook('rightColumn'))
        )
        {
            // If there are no colums implemented by the template, throw an error and uninstall the module
            $this->_errors[] = $this->l('This module needs to be hooked to a column, but your theme does not implement one');
            parent::uninstall();
            return false;
        }

 

puis en bas de page , j'ai copié la fonction hookRightColumn() et l'ai renommée hookRightColumnProduct

cf ci dessous :

 

public function hookRightColumn($params)
    {
        if (!$this->isCached('blockadvertising.tpl', $this->getCacheId()))
            $this->smarty->assign(
                array(
                    'image' => $this->context->link->protocol_content.$this->adv_img,
                    'adv_link' => $this->adv_link,
                    'adv_title' => $this->adv_title,
                )
            );

        return $this->display(__FILE__, 'blockadvertising.tpl', $this->getCacheId());
    }
/*copie pr adapter à rightcolumnproduct*/
public function hookRightColumnProduct($params)
    {
        if (!$this->isCached('blockadvertising.tpl', $this->getCacheId()))
            $this->smarty->assign(
                array(
                    'image' => $this->context->link->protocol_content.$this->adv_img,
                    'adv_link' => $this->adv_link,
                    'adv_title' => $this->adv_title,
                )
            );

        return $this->display(__FILE__, 'blockadvertising.tpl', $this->getCacheId());
    }
/**/

    public function hookLeftColumn($params)
    {
        return $this->hookRightColumn($params);
    }
 

 

Ensuite, ds product.tpl, j'ai rajouté le nouveau hook : cf:

 

{if isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS}{$HOOK_PRODUCT_ACTIONS}{/if}
                    </div> <!-- end box-cart-bottom -->
                </div> <!-- end box-info-product -->
                 <!-- ajout de mon nouveau hook -->
                {hook h='displayUnderProductButtons'}
                
            </form>

 

Ensuite, j'ai mis à jour le module publicité dans prestashop, et je suis allée ds position pour greffer le module Pub sur mon nouveau hook, mais voilà, je ne le vois pas ?

 

J'ai zappé quelque chose ?

 

Est ce qu'il faudrait rajouter ça aussi  ?? ou c'est suffisant juste sur hookRightColumn ?

public function hookDisplayUnderProductButtons($params)
    {
        return $this->hookRightColumnProduct($params);
    }
    /**/

 

merci beaucoup en tous cas!!

Link to comment
Share on other sites

Ton fichier blockadvertising.php devrait ressembler à ça :

<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

if (!defined('_PS_VERSION_'))
    exit;

class BlockAdvertising extends Module
{
    /* Title associated to the image */
    public $adv_title;

    /* Link associated to the image */
    public $adv_link;

    /* Name of the image without extension */
    public $adv_imgname;

    /* Image path with extension */
    public $adv_img;

    public function __construct()
    {
        $this->name = 'blockadvertising';
        $this->tab = 'advertising_marketing';
        $this->version = '0.9.3';
        $this->author = 'PrestaShop';
        $this->need_instance = 0;

        $this->bootstrap = true;
        parent::__construct();

        $this->displayName = $this->l('Advertising block');
        $this->description = $this->l('Adds an advertisement block to selected sections of your e-commerce website.');
        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);

        $this->initialize();
    }

    /*
     * Set the properties of the module, like the link to the image and the title (contextual to the current shop context)
     */
    protected function initialize()
    {
        $this->adv_imgname = 'advertising';
        if ((Shop::getContext() == Shop::CONTEXT_GROUP || Shop::getContext() == Shop::CONTEXT_SHOP)
            && file_exists(_PS_MODULE_DIR_.$this->name.'/img/'.$this->adv_imgname.'-g'.$this->context->shop->getContextShopGroupID().'.'.Configuration::get('BLOCKADVERT_IMG_EXT'))
        )
            $this->adv_imgname .= '-g'.$this->context->shop->getContextShopGroupID();
        if (Shop::getContext() == Shop::CONTEXT_SHOP
            && file_exists(_PS_MODULE_DIR_.$this->name.'/img/'.$this->adv_imgname.'-s'.$this->context->shop->getContextShopID().'.'.Configuration::get('BLOCKADVERT_IMG_EXT'))
        )
            $this->adv_imgname .= '-s'.$this->context->shop->getContextShopID();

        // If none of them available go default
        if ($this->adv_imgname == 'advertising')
            $this->adv_img = Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/img/fixtures/'.$this->adv_imgname.'.jpg';
        else
            $this->adv_img = Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/img/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT');
        $this->adv_link = htmlentities(Configuration::get('BLOCKADVERT_LINK'), ENT_QUOTES, 'UTF-8');
        $this->adv_title = htmlentities(Configuration::get('BLOCKADVERT_TITLE'), ENT_QUOTES, 'UTF-8');
    }

    public function install()
    {
        if (!parent::install())
            return false;

        // Hook the module either on the left or right column
        $theme = new Theme(Context::getContext()->shop->id_theme);
        !$this->registerHook('displayUnderProductButtons');
        if ((!$theme->default_left_column || !$this->registerHook('leftColumn'))
            && (!$theme->default_right_column || !$this->registerHook('rightColumn'))
        )
        {
            // If there are no colums implemented by the template, throw an error and uninstall the module
            $this->_errors[] = $this->l('This module needs to be hooked to a column, but your theme does not implement one');
            parent::uninstall();

            return false;
        }

        Configuration::updateGlobalValue('BLOCKADVERT_LINK', 'http://www.prestashop.com/');
        Configuration::updateGlobalValue('BLOCKADVERT_TITLE', 'PrestaShop');
        // Try to update with the extension of the image that exists in the module directory
        foreach (scandir(_PS_MODULE_DIR_.$this->name) as $file)
            if (in_array($file, array('advertising.jpg', 'advertising.gif', 'advertising.png')))
                Configuration::updateGlobalValue('BLOCKADVERT_IMG_EXT', substr($file, strrpos($file, '.') + 1));

        return true;
    }

    public function uninstall()
    {
        Configuration::deleteByName('BLOCKADVERT_LINK');
        Configuration::deleteByName('BLOCKADVERT_TITLE');
        Configuration::deleteByName('BLOCKADVERT_IMG_EXT');

        return (parent::uninstall());
    }

    /**
     * delete the contextual image (it is not allowed to delete the default image)
     *
     * @return void
     */
    private function _deleteCurrentImg()
    {
        // Delete the image file
        if ($this->adv_imgname != 'advertising' && file_exists(_PS_MODULE_DIR_.$this->name.'/img/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
            unlink(_PS_MODULE_DIR_.$this->name.'/img/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT'));

        // Update the extension to the global value or the shop group value if available
        Configuration::deleteFromContext('BLOCKADVERT_IMG_EXT');
        Configuration::updateValue('BLOCKADVERT_IMG_EXT', Configuration::get('BLOCKADVERT_IMG_EXT'));

        // Reset the properties of the module
        $this->initialize();
    }

    public function postProcess()
    {
        if (Tools::isSubmit('submitDeleteImgConf'))
            $this->_deleteCurrentImg();

        $errors = '';
        if (Tools::isSubmit('submitAdvConf'))
        {
            if (isset($_FILES['adv_img']) && isset($_FILES['adv_img']['tmp_name']) && !empty($_FILES['adv_img']['tmp_name']))
            {
                if ($error = ImageManager::validateUpload($_FILES['adv_img'], Tools::convertBytes(ini_get('upload_max_filesize'))))
                    $errors .= $error;
                else
                {
                    Configuration::updateValue('BLOCKADVERT_IMG_EXT', substr($_FILES['adv_img']['name'], strrpos($_FILES['adv_img']['name'], '.') + 1));

                    // Set the image name with a name contextual to the shop context
                    $this->adv_imgname = 'advertising';
                    if (Shop::getContext() == Shop::CONTEXT_GROUP)
                        $this->adv_imgname = 'advertising-g'.(int)$this->context->shop->getContextShopGroupID();
                    elseif (Shop::getContext() == Shop::CONTEXT_SHOP)
                        $this->adv_imgname = 'advertising-s'.(int)$this->context->shop->getContextShopID();

                    // Copy the image in the module directory with its new name
                    if (!move_uploaded_file($_FILES['adv_img']['tmp_name'], _PS_MODULE_DIR_.$this->name.'/img/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
                        $errors .= $this->l('File upload error.');
                }
            }

            // If the link is not set, then delete it in order to use the next default value (either the global value or the group value)
            if ($link = Tools::getValue('adv_link'))
                Configuration::updateValue('BLOCKADVERT_LINK', $link);
            elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
                Configuration::deleteFromContext('BLOCKADVERT_LINK');

            // If the title is not set, then delete it in order to use the next default value (either the global value or the group value)
            if ($title = Tools::getValue('adv_title'))
                Configuration::updateValue('BLOCKADVERT_TITLE', $title);
            elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
                Configuration::deleteFromContext('BLOCKADVERT_TITLE');

            // Reset the module properties
            $this->initialize();
            $this->_clearCache('blockadvertising.tpl');

            if (!$errors)
                Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&conf=6');
            echo $this->displayError($errors);
        }

    }

    /**
     * getContent used to display admin module form
     *
     * @return string content
     */
    public function getContent()
    {
        $this->postProcess();

        return $this->renderForm();
    }

    public function hookRightColumn($params)
    {
        if (!$this->isCached('blockadvertising.tpl', $this->getCacheId()))
            $this->smarty->assign(
                array(
                    'image' => $this->context->link->protocol_content.$this->adv_img,
                    'adv_link' => $this->adv_link,
                    'adv_title' => $this->adv_title,
                )
            );

        return $this->display(__FILE__, 'blockadvertising.tpl', $this->getCacheId());
    }

    public function hookLeftColumn($params)
    {
        return $this->hookRightColumn($params);
    }

    public function hookDisplayUnderProductButtons($params)
    {
        return $this->hookRightColumn($params);
    }

    public function hookHeader($params)
    {
        $this->context->controller->addCSS($this->_path.'blockadvertising.css', 'all');
    }

    public function renderForm()
    {
        $fields_form = array(
            'form' => array(
                'legend' => array(
                    'title' => $this->l('Configuration'),
                    'icon' => 'icon-cogs'
                ),
                'input' => array(
                    array(
                        'type' => 'file',
                        'label' => $this->l('Image for the advertisement'),
                        'name' => 'adv_img',
                        'desc' => $this->l('By default the image will appear in the left column. The recommended dimensions are 155 x 163px.'),
                        'thumb' => $this->context->link->protocol_content.$this->adv_img,
                    ),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Target link for the image'),
                        'name' => 'adv_link',
                    ),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Title of the target link'),
                        'name' => 'adv_title',
                        'desc' => $this->l('This title will be displayed when you mouse over the advertisement block in your shop.')
                    ),
                ),
                'submit' => array(
                    'title' => $this->l('Save'),
                )
            ),
        );

        $helper = new HelperForm();
        $helper->show_toolbar = false;
        $helper->table = $this->table;
        $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
        $helper->default_form_language = $lang->id;
        $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
        $this->fields_form = array();
        $helper->id = (int)Tools::getValue('id_carrier');
        $helper->identifier = $this->identifier;
        $helper->submit_action = 'submitAdvConf';
        $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
        $helper->token = Tools::getAdminTokenLite('AdminModules');
        $helper->tpl_vars = array(
            'fields_value' => $this->getConfigFieldsValues(),
            'languages' => $this->context->controller->getLanguages(),
            'id_language' => $this->context->language->id
        );

        return $helper->generateForm(array($fields_form));
    }

    public function getConfigFieldsValues()
    {
        return array(
            'adv_link' => Tools::getValue('adv_link', Configuration::get('BLOCKADVERT_LINK')),
            'adv_title' => Tools::getValue('adv_title', Configuration::get('BLOCKADVERT_TITLE')),
        );
    }
}

Et faut bien réinitialiser le module sinon tu verras pas ton nouveau hook dans la liste des greffes

 

(Mais a la réinitialisation il s'y installe automatiquement puisque qu'on a mis : !$this->registerHook('displayUnderProductButtons'); )

Edited by anteverce (see edit history)
Link to comment
Share on other sites

Eh bien c'est fou, ça ne fonctionne toujours pas,

j'ai entièrement copié ton code php ci dessus, et je l'ai mis à la place de mon code ds blockadvertising.php, j'ai remis en ligne, j'ai remis à jour le module, vider l'historique du navigateur, je me suis deconnectee et reconnectee à la boutique, eh bien le hook n'apparait toujours pas ds la liste?

Il devrait apparaitre sous DisplayTopColumn normalement..

Mais donc, quand tu dis 'réinitialiser le module', ça veut bien dire Cliquer sur Module à mettre à jour ou Verifier les mises à jour dans la partie Modules, c’est bien ça?

Sinon, je doute que ce soit un pb de bloqueur de pub, c'est le hook qui n'apparait carrément pas, pas juste l'encart de pub..non ?

Pourtant il me semble avoir fait tout ce que tu m'as indiqué ? le fichier php, le product.tpl, et la mise à jour du module

Alors, est ce que ce serait dans product.tpl ??

vers la ligne 390 j'ai ça :

 {if isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS}{$HOOK_PRODUCT_ACTIONS}{/if}
                    </div> <!-- end box-cart-bottom -->
                </div> <!-- end box-info-product -->
                
                 <!-- ajout de mon nouveau hook -->
                {hook h='displayUnderProductButtons'}
                
            </form>
            {/if}
        </div> <!-- end pb-right-column-->

 

 

pas simple ..

Link to comment
Share on other sites

Mais donc, quand tu dis 'réinitialiser le module', ça veut bien dire Cliquer sur Module à mettre à jour ou Verifier les mises à jour dans la partie Modules, c’est bien ça?

Dans ta liste des modules, tu trouves celui concerné, clique sur la petite flèche, et choisis réinitialiser.

 

Sinon pour ton hook, il devrait apparaître sous le nom displayUnderProductButtons tout simplement, mais pas forcément par ordre alphabétique je crois. Fais un petit coup de Ctrl+F pour chercher directement dans la page, et pense à afficher les points d'ancrage invisibles si jamais tu le trouves pas ( on sait jamais :) )

  • Like 1
Link to comment
Share on other sites

YESSSSSSS!

Merci, c'est tout bon!

Voilà, c'est que je ne réinitialisais pas le module, je faisais 'Mettre à jour', au lieu d'aller dans la liste à droite qui permet de Réinitialiser.

Impeccable, ça marche et j'ai appris pleins de choses!

Merci encore!

  • Like 1
Link to comment
Share on other sites

Voilà a quoi sert le forum : Aider les gens ^^

 

Cool je viens de voir le résultat c'est plus joli en effet :)

 

PS : Si Prestashop te dis de mettre a jour le module Blockadvertising fait attention ! Car ca effacera toutes tes modifications !

Edited by anteverce (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...