Jump to content

[FREE TUTORIAL] How to add hooks to Prestashop CMS pages


Recommended Posts

  • 2 months later...

Hm well yeah, if Benjamin Utterback reads your post :D Thanks!

 

Hey everyone! Following up a post in the forums I just wrote a short article on how to add hooks to cms pages, and target specific ones too, here it is!

 

http://nemops.com/how-to-hooks-prestashop-cms/#.U_RXL_na6r0

 

Cheers!

 

Hi Nemo1, This a great tutorial by the way! I would like to take this approach further by adding the newsletter block into my cms page. Right now I have a Pop Up that I bought from Vekia, which works great but in this pop up I would like to add the newsletter block so customers could sign up for deals and so forth.

 

I would assume the files that need to be touched are /modules/blocknewsletter/newsletter.php At the moment I am totally lost on where to place the file that you gave in the example:

 

I tried placing it here but my site produces a blank page. (/newsletter.php)

 

    public function install()

    {

        if (!parent::install() || !$this->registerHook(array('header', 'footer', 'actionCustomerAccountAdd')))

            return false;

|| !$this->registerHook('customCMS')

 

I am currently using the default template for Prestashop 1.6.0.9 and my goal is to get the newsletter hook (Enter your e-mail) into a pop up. (http://mypresta.eu/modules/front-office-features/prestashop-popup-pro.html)

 

Any thoughts how I can make this work?

Link to comment
Share on other sites

 

 

I am currently using the default template for Prestashop 1.6.0.9 and my goal is to get the newsletter hook (Enter your e-mail) into a pop up. (http://mypresta.eu/modules/front-office-features/prestashop-popup-pro.html)

 

Any thoughts how I can make this work?

 

module allows to use custom code, you don't need hook to place custom code inside module.

it means that you can create signup form without core / theme modifications.

just paste code with form to popup.

Link to comment
Share on other sites

module allows to use custom code, you don't need hook to place custom code inside module.

it means that you can create signup form without core / theme modifications.

just paste code with form to popup.

 

Hi Vekia, I have the custom code ready to go:

 

<form id="form1" name="form1" method="post" action="">

  <label for="email">email</label>

    <input type="text" name="email" id="email" />

</form>

 

When a customer comes to my site, the pop up shows and inside the pop up is the email form. How would I make the connection to the database when the customer clicks the submit button? I have searched for examples but none come close to what I am trying to achieve. If I can get this working, then this would be a great advantage to your pop up module.

Link to comment
Share on other sites

Hi Vekia, I have the custom code ready to go:

 

<form id="form1" name="form1" method="post" action="">

  <label for="email">email</label>

    <input type="text" name="email" id="email" />

</form>

 

When a customer comes to my site, the pop up shows and inside the pop up is the email form. How would I make the connection to the database when the customer clicks the submit button? I have searched for examples but none come close to what I am trying to achieve. If I can get this working, then this would be a great advantage to your pop up module.

 

 

if you will use newsletter module (installed and enabled), use the same <form> id and name, the same with <input> fields

after submit, module will insert these datas into database

 

if you want to use own <input> totally not related to newsletter module you have to create php script to handle form datas

Link to comment
Share on other sites

  • 4 weeks later...

Hi Vekia and Nemo, how would you transplant modules to custom hooks with the newest version of prestashop?

 

As the module files are no longer .php extensions but tpl and the advice given above seems to not be working anymore?

 

If you could just help me out with this, it would be greatly appreciated. thank you.

Link to comment
Share on other sites

  • 4 months later...

Vekia's module?

In any case, you need to make sure you target the proper ID

No, emotionloop´s module 'contentbox' the <if> restriction it´s the same for  prestashop 1.6.0.13 ? also it´s in the php module file or it´s in the tpl CMS file? : ( 

Link to comment
Share on other sites

Yes, it's the same. You can do it from the php side, or smarty's, but I'd suggest using php and return false in case the id doesn't match

if(Tools::getValue('id_cms') != 2) return false;

Unless you are using some id-removal module that doesn't reassign the id_cms value

Link to comment
Share on other sites

Hello evrybody... Hope somebody can help.

 

I'm using Prestashop (version 1.6.0.14) along with Warehouse theme (http://warehouse.iqit-commerce.com/selector/index1.html) which comes with Revolution Slider (http://revolution.themepunch.com/prestashop/)...

 

Revoltion Slider lets me choose in which hook to appear but its limited to home page.

 

The idea is to create a custom hook for CMS pages and insert the Revolution Slider in there.

 

I've tried to follow the tutorial to create a custom hook, without success...

 

Can anybody explain in dummy words how to achieve this purpose?

 

 

Thanks in advance...

Link to comment
Share on other sites

  • 5 months later...

Vekia's module?

In any case, you need to make sure you target the proper ID

Hi Nemo1,

 

I'm experiencing a problem trying to display html page with content box with your tutorial,

 

I changed the cms.tp like this :

 

<!-- hook module -->

 

{if !$content_only}

{hook h='customCMS'}

{/if}

 

 

<!-- hook module -->

 

 

    <div class="rte{if $content_only} content_only{/if}">

        {$cms->content}

    </div>

 

 

I changed the contentbox.php like this :

 

public function install()

    {

        if (Shop::isFeatureActive())

            Shop::setContext(Shop::CONTEXT_ALL);

 

        if (!parent::install()

            || !$this->registerHook('header')

            || !$this->registerHook('footer')         

            || !$this->registerHook('customCMS')          

            ||  !CONTENTBOXModel::createTables())

            return false;

 

        Configuration::updateValue($this->monolanguage_content, 0);

        Configuration::updateValue($this->text_editor_content, 1);

 

        Configuration::updateValue($this->content_wrapper, 0);

        Configuration::updateValue($this->content_wrapper_class, '');

        Configuration::updateValue($this->content_wrapper_id, '');

 

        $this->_clearCache('template.tpl');

 

        return true;

    }

 

And added theses code at the end of the contentbox.php :

 

 

public function hookcustomCMS($params)

{

    return $this->hookDisplayHome($params);

}

 

 

 

}

 

 

Thank you by advance for your help, here is the page i tried to modify : http://pariscave.com/content/7-accueil

Link to comment
Share on other sites

  • 8 months later...

Hey everyone! Following up a post in the forums I just wrote a short article on how to add hooks to cms pages, and target specific ones too, here it is!

 

http://nemops.com/how-to-hooks-prestashop-cms/#.U_RXL_na6r0

 

Cheers!

Thanks for this really helpful tutorial!

There is a small typo though which might confuse those who are not so familiar with themes.

There is a line that reads

"Locate your cms.tpl inside the module’s folder"

which should actually be

"Locate your cms.tpl inside the theme’s folder"

 

This tutorial was exactly what I was looking for. Thanks so much! It works like a charm.

Link to comment
Share on other sites

  • 1 month later...

Hey guys,

 

Were there any changes in contentbox that broke the hooking method explained in tutorial?

I cannot seem to get it working.. 

I'd like content box to appear in one cms page, yet still getting it on all of them..

PS 1.6.0.11 contentbox v1.1.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...