Jump to content

Hook block infos contact, Help html


Recommended Posts

Bonjour à tous,

 

Je suis en train de développer ma première boutique prestashop & aprés avoir changer de template j'ai du mal à repositionner mes modules.

 

J'ai mon block infos contact que je souhaiterais voir sur ma home page dans la section LeftColumn.

 

J'ai essayé de modifié le code php sur mon ftp, mais étant novice je ne parviens pas à mes fins.

 

Je vous mets ci-dessous le code actuel de ma page, pourriez-vous m'indiquer où mettre la nouvelle commande pour introduire le hook de la LeftColumn et surtout m'expliquer le fonctionnement pour que je puisse me débrouiller seul par la suite ?

 

Merci énormément,

 

Troy.

 

class Blockcontactinfos extends Module
{
    public function __construct()
    {
        $this->name = 'blockcontactinfos';
        if (version_compare(_PS_VERSION_, '1.4.0.0') >= 0)
            $this->tab = 'front_office_features';
        else
            $this->tab = 'Blocks';
        $this->version = '1.0';

        parent::__construct();

        $this->displayName = $this->l('Block contact info');
        $this->description = $this->l('This module will allow you to display your e-store\'s contact information in a customizable block.');
    }
    
    public function install()
    {
        return (parent::install()
                && Configuration::updateValue('blockcontactinfos_company', Configuration::get('PS_SHOP_NAME'))
                && Configuration::updateValue('blockcontactinfos_address', '') && Configuration::updateValue('blockcontactinfos_phone', '')
                && Configuration::updateValue('blockcontactinfos_email', Configuration::get('PS_SHOP_EMAIL'))
                && $this->registerHook('header') && $this->registerHook('footer'));
    }
    
    public function uninstall()
    {
        //Delete configuration            
        return (Configuration::deleteByName('blockcontactinfos_company')
                && Configuration::deleteByName('blockcontactinfos_address') && Configuration::deleteByName('blockcontactinfos_phone')
                && Configuration::deleteByName('blockcontactinfos_email') && parent::uninstall());
    }
    
    public function getContent()
    {
        $html = '';
        // If we try to update the settings
        if (isset($_POST['submitModule']))
        {    
            Configuration::updateValue('blockcontactinfos_company', ((isset($_POST['company']) && $_POST['company'] != '') ? $_POST['company'] : Configuration::get('PS_SHOP_NAME')));
            Configuration::updateValue('blockcontactinfos_address', ((isset($_POST['address']) && $_POST['address'] != '') ? $_POST['address'] : ''));
            Configuration::updateValue('blockcontactinfos_phone', ((isset($_POST['phone']) && $_POST['phone'] != '') ? $_POST['phone'] : ''));
            Configuration::updateValue('blockcontactinfos_email', ((isset($_POST['email']) && $_POST['email'] != '') ? $_POST['email'] : Configuration::get('PS_SHOP_EMAIL')));
            $this->_clearCache('blockcontactinfos.tpl');
            $html .= '<div class="conf confirm">'.$this->l('Configuration updated').'</div>';
        }

        $html .= '
        <h2>'.$this->displayName.'</h2>
        <form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post">
            <fieldset>    
                <p><label for="company">'.$this->l('Company name').' :</label>
                <input type="text" id="company" name="company" value="'.Tools::safeOutput(Configuration::get('blockcontactinfos_company')).'" /></p>
                <p><label for="address">'.$this->l('Address').' :</label>
                <textarea id="address" name="address" cols="60" rows="4">'.Tools::safeOutput(Configuration::get('blockcontactinfos_address')).'</textarea></p>
                <p><label for="phone">'.$this->l('Phone number').' :</label>
                <input type="text" id="phone" name="phone" value="'.Tools::safeOutput(Configuration::get('blockcontactinfos_phone')).'" /></p>
                <p><label for="email">'.$this->l('Email').' :</label>
                <input type="text" id="email" name="email" value="'.Tools::safeOutput(Configuration::get('blockcontactinfos_email')).'" />    </p>
                <div class="margin-form">
                    <input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center>
                </div>
            </fieldset>
        </form>
        ';
        
        return $html;
    }
    
    public function hookHeader()
    {
        $this->context->controller->addCSS(($this->_path).'blockcontactinfos.css', 'all');
    }
    
    public function hookFooter($params)
    {    
        if (!$this->isCached('blockcontactinfos.tpl', $this->getCacheId()))
            $this->smarty->assign(array(
                'blockcontactinfos_company' => Configuration::get('blockcontactinfos_company'),
                'blockcontactinfos_address' => Configuration::get('blockcontactinfos_address'),
                'blockcontactinfos_phone' => Configuration::get('blockcontactinfos_phone'),
                'blockcontactinfos_email' => Configuration::get('blockcontactinfos_email')
            ));
        return $this->display(__FILE__, 'blockcontactinfos.tpl', $this->getCacheId());
    }
}
?>

 

Link to comment
Share on other sites

Bonjour

 

Merci de lire les conseils et les règles avant de poster et de créer votre topic dans le bon forum.

Sur chaque forum est précisé le thème et contenu.

 

Topic déplacé ou supprimer :) bon je vais rester gentil :)

 

http://www.prestashop.com/forums/forum/120-d%C3%A9veloppement-et-adaptation-de-prestashop/

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

public function install()
    {
        return (parent::install()
                && Configuration::updateValue('blockcontactinfos_company', Configuration::get('PS_SHOP_NAME'))
                && Configuration::updateValue('blockcontactinfos_address', '') && Configuration::updateValue('blockcontactinfos_phone', '')
                && Configuration::updateValue('blockcontactinfos_email', Configuration::get('PS_SHOP_EMAIL'))
                && $this->registerHook('header') && $this->registerHook('footer'));
                && $this->registerHook('leftcolumn'));  

 

  }

 

  and make a function :

 

 public function hookLeftColumn()
    {
        call content  file that you want to show 
    }

   

Edited by Er.Ritesh (see edit history)
Link to comment
Share on other sites

Thank you for ur answer but now my "position" page in my back office is white .... I dont know what i did wrong

 

class Blockcontactinfos extends Module
{
    public function __construct()
    {
        $this->name = 'blockcontactinfos';
        if (version_compare(_PS_VERSION_, '1.4.0.0') >= 0)
            $this->tab = 'front_office_features';
        else
            $this->tab = 'Blocks';
        $this->version = '1.0';

        parent::__construct();

        $this->displayName = $this->l('Block contact info');
        $this->description = $this->l('This module will allow you to display your e-store\'s contact information in a customizable block.');
    }

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

    public function install()
    {
        return (parent::install()
                && Configuration::updateValue('blockcontactinfos_company', Configuration::get('PS_SHOP_NAME'))
                && Configuration::updateValue('blockcontactinfos_address', '') && Configuration::updateValue('blockcontactinfos_phone', '')
                && Configuration::updateValue('blockcontactinfos_email', Configuration::get('PS_SHOP_EMAIL'))
                && $this->registerHook('header') && $this->registerHook('footer'));
                && $this->registerHook('leftcolumn'));  
    }
    
    public function uninstall()
    {
        //Delete configuration            
        return (Configuration::deleteByName('blockcontactinfos_company')
                && Configuration::deleteByName('blockcontactinfos_address') && Configuration::deleteByName('blockcontactinfos_phone')
                && Configuration::deleteByName('blockcontactinfos_email') && parent::uninstall());
    }
 

Link to comment
Share on other sites

css file also call header hook:

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

and template file call

 

public function hookLeftColumn()
        {
            template file
        }

Link to comment
Share on other sites

    Ajoutez ces lignes dans votre php et greffez le module au hook via le BO.

En fait vous récupérez les paramètres du footer. Vous pouvez faire pareil pour le colonne de droite.

Après il faudra peut être ajuster le css

public function hookLeftColumn($params)
    {
        return $this->hookFooter($params);
    }
Edited by Bondaty and Co (see edit history)
  • Like 1
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...