Hello, Guest |
| Register
Remember me Forgot password ?
Site Map Site Map Contact us Contact us
PrestaShop e-commerce software
  769 users online
Forum  >  English Forum  >  Third party modules  >  Thread

1 of 2
1
Post Reply
New Topic
[ SOLUTION] Create Hooks in 6 easy steps!

offline
Posted: 12 February 2009 05:41 AM   [ Ignore ]
Regular
RankRank
Avatar

Messages :

  • total: 92
  • last 7 days: 0
Joined: 2009-01-15

Took me quite a while and lots of meddling to figure this out… thought I would share with the rest of you guys on how to create a hook so u can NOT waste the number of hours like I did smile

1. Goto your database and modify ps_hook… (ps_ is what I named my database, so it can be replaced by what you named yours.)

2. find the last id_hook number and insert a new number after with the hook that you want to name e.g. I name it ‘cat’

3. goto the php of the pages you want the hook to be in… e.g footer.php

4. insert ‘HOOK_CAT’ => Module::hookExec(‘cat’), into the below

$smarty->assign(array(
        
'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn'),
        
'HOOK_FOOTER' => Module::hookExec('footer'),
        
'content_only' => intval(Tools::getValue('content_only'))));
        
$smarty->display(_PS_THEME_DIR_.'footer.tpl');

5. this is the final code…

$smarty->assign(array(
        
'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn'),
        
'HOOK_FOOTER' => Module::hookExec('footer'),
        
'HOOK_CAT' => Module::hookExec('cat'),
        
'content_only' => intval(Tools::getValue('content_only'))));
        
$smarty->display(_PS_THEME_DIR_.'footer.tpl');

6.insert {$HOOK_CAT} into where you want in footer.tpl and you are in business

NOTE : For the hook to appear YOU HAVE TO assign the array in the page’s php… Would be good if we can have a master HOOK array list…

 Signature 

----------------------------------------
http://www.zuigeling.com
http://www.iputa.com
http://www.alfredtay.com
----------------------------------------

 
offline
Posted: 17 February 2009 04:03 PM   [ Ignore ]   [ # 1 ]
Newcomer
Rank

Messages :

  • total: 5
  • last 7 days: 0
Joined: 2009-01-28

I want to re-position the adv block to center content area, I have followed you instruction, but got no result.
i have found in blockadvertising.php
line no 19 function install() { if (!parent::install()) return false; if (!$this->registerHook(‘rightColumn’) OR !$this->registerHook(‘leftColumn’) OR !$this->registerHook(‘adv’)) return false; return true; }
Is there any way to display the Advertisement block in center content area below “featured products” ?? cool smile

 Signature 

http://www.webdesigner-logodesign.com

 
offline
Posted: 17 February 2009 04:36 PM   [ Ignore ]   [ # 2 ]
V.I.P.
RankRankRankRank
Avatar

Messages :

  • total: 905
  • last 7 days: 1
Joined: 2008-07-17

Well, if you want to have the advertising in your home page, in the center area, you don’t have to add a new Hook, because there is the ‘home’ hook.

You will have to change your function install() in blockadvertising with :

function install()
    
{
        
if (!parent::install())
            return 
false;
        if (!
$this->registerHook('rightColumn') OR !$this->registerHook('leftColumn') OR !this->registerHook('home'))
            return 
false;
        return 
true;
    
}

And add the function :

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

But may I suggest you to use my module instead ? you’ll be able to add and modify elements like swf files or pictures with link on it (juste like blockadvertising) in different places (like home, top, left column, right column, and footer.). You can download it >> HERE <<

And, for sperio : This is a good solution to add new Hooks, and I’m working on finding a global array. I’ll make some tests soon.

 Signature 

logo_SotEWsStuff.png
http://sotew.com/
Add content on your PrestaShop website (pictures, flash, html and SLIDESHOW) with AddBlocks V0.1.3 logo.gif
Demo website: http://demo.sotew.com/ - http://demo.sotew.com/back/
Donate ?

 
offline
Posted: 18 February 2009 07:19 AM   [ Ignore ]   [ # 3 ]
Newcomer
Rank

Messages :

  • total: 5
  • last 7 days: 0
Joined: 2009-01-28

thanks SotEW
This code is working grin

Image Attachments
pic_004.jpg
 Signature 

http://www.webdesigner-logodesign.com

 
offline
Posted: 18 February 2009 07:26 AM   [ Ignore ]   [ # 4 ]
Regular
RankRank
Avatar

Messages :

  • total: 92
  • last 7 days: 0
Joined: 2009-01-15

glad you guys like it

 Signature 

----------------------------------------
http://www.zuigeling.com
http://www.iputa.com
http://www.alfredtay.com
----------------------------------------

 
offline
Posted: 18 February 2009 09:08 AM   [ Ignore ]   [ # 5 ]
V.I.P.
RankRankRankRank
Avatar

Messages :

  • total: 970
  • last 7 days: 0
Joined: 2009-01-06

thanks for tutorial

 Signature 

Free Prestashop Theme from Wordpress Theme
Follow me ardianys
Download iNove Free Prestashop Theme

 
offline
Posted: 21 March 2009 04:25 PM   [ Ignore ]   [ # 6 ]
Beginner
Rank

Messages :

  • total: 15
  • last 7 days: 0
Joined: 2009-03-12

And if i want Block Specials and New Product Block in Homepage? I have tried this code to blockspecials.php but the modules page in the admin side is blank.

 
offline
Posted: 21 March 2009 04:50 PM   [ Ignore ]   [ # 7 ]
V.I.P.
RankRankRankRank
Avatar

Messages :

  • total: 905
  • last 7 days: 1
Joined: 2008-07-17

DannyIDC, If your modules page in the admin side is blank, it’s because you put a mistake in blockspecials.php or blocknewproducts.php.

Reset your files and try again wink

 Signature 

logo_SotEWsStuff.png
http://sotew.com/
Add content on your PrestaShop website (pictures, flash, html and SLIDESHOW) with AddBlocks V0.1.3 logo.gif
Demo website: http://demo.sotew.com/ - http://demo.sotew.com/back/
Donate ?

 
offline
Posted: 21 March 2009 05:03 PM   [ Ignore ]   [ # 8 ]
Beginner
Rank

Messages :

  • total: 15
  • last 7 days: 0
Joined: 2009-03-12

See the file please and tell me where’s the problem, please smile

File Attachments
blockspecials.php  (File Size: 2KB - Downloads: 269)
 
offline
Posted: 21 March 2009 07:24 PM   [ Ignore ]   [ # 9 ]
V.I.P.
RankRankRankRank
Avatar

Messages :

  • total: 905
  • last 7 days: 1
Joined: 2008-07-17

You’ve got two little mistakes :

you forgot one dollar here : (line 27)

if (!$this->registerHook('rightColumn') OR !$this->registerHook('leftColumn') OR !$this->registerHook('home'))

and a bracet at the end

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

}                    
<< here
?>

Don’t forget to comment the hook you don’t want in the install function. (with the file you give me, you’ve got the blocspecials in the left column, AND in the right column, AND in the home.)

Don’t forget also that you will not display the specials the same way in a column or in the home !! I suggest you to replace the function hookHome with a duplicate of the hookRightColumn function, and rename the .tpl returned (and create it.)

Gook Luck !!

 Signature 

logo_SotEWsStuff.png
http://sotew.com/
Add content on your PrestaShop website (pictures, flash, html and SLIDESHOW) with AddBlocks V0.1.3 logo.gif
Demo website: http://demo.sotew.com/ - http://demo.sotew.com/back/
Donate ?

 
offline
Posted: 21 March 2009 08:14 PM   [ Ignore ]   [ # 10 ]
Beginner
Rank

Messages :

  • total: 15
  • last 7 days: 0
Joined: 2009-03-12

Works good! Thanks a lot. wink

 
offline
Posted: 27 March 2009 08:58 PM   [ Ignore ]   [ # 11 ]
Senior Member
RankRankRank
Avatar

Messages :

  • total: 341
  • last 7 days: 14
Joined: 2008-11-12

i am adds a block to header bottom. but this area is 2 row. i need one row.

 
offline
Posted: 23 April 2009 05:49 PM   [ Ignore ]   [ # 12 ]
Senior Member
RankRankRank
Avatar

Messages :

  • total: 302
  • last 7 days: 0
Joined: 2009-01-02

works well, thanks for the info.

all the best,
cerberus22

 Signature 

Using Prestashop V1.1

 
offline
Posted: 06 May 2009 01:22 PM   [ Ignore ]   [ # 13 ]
Newcomer
Rank

Messages :

  • total: 3
  • last 7 days: 0
Joined: 2009-05-06

Thanks for the tutorial.. saved me hours

 
offline
Posted: 04 June 2009 03:34 PM   [ Ignore ]   [ # 14 ]
Regular
RankRank
Avatar

Messages :

  • total: 92
  • last 7 days: 0
Joined: 2009-01-15

we can help if you would provide us with the problem smile

 Signature 

----------------------------------------
http://www.zuigeling.com
http://www.iputa.com
http://www.alfredtay.com
----------------------------------------

 
offline
Posted: 30 June 2009 07:19 PM   [ Ignore ]   [ # 15 ]
Newcomer
Rank

Messages :

  • total: 4
  • last 7 days: 0
Joined: 2009-01-14

As I was browsing through this thread I realized you never explained how to register a module with your new custom hook. I was attempting to insert the permanent links block into a new hook below the top and I used the following code:

I replaced

if (!$this->registerHook('top'))

with
if (!$this->registerHook('top') or !$this->registerHook('upperColumn'))

AND

I inserted this function

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

It actually worked, but I’m not sure why. I understand that !$this->registerHook(‘upperColumn’) would install the module in the hook with ‘upperColumn’ as an ID, but what is the relevance of function hookUpperColumn? I don’t see the module calling it anywhere.

cheers,
Swift


EDIT: Actually I was mistaken. The module is being displayed in the center column, why?

 
 
1 of 2
1
Fast Reply
New Topic