Guest User

Untitled

a guest
Jun 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?php
  2. if (!defined('_PS_VERSION_'))
  3. exit;
  4.  
  5. class TopMenu extends Module {
  6.  
  7. public function __construct()
  8. {
  9. $this->name = 'topmenu';
  10. $this->tab = 'top menu';
  11. $this->version = '0.3';
  12. $this->author = 'PrestaShop';
  13. $this->need_instance = 0;
  14.  
  15. parent::__construct();
  16.  
  17. $this->displayName = $this->l('Top Menu');
  18. $this->description = $this->l('Adds a block to display an top menu.');
  19.  
  20. }
  21.  
  22. public function install(){
  23. // let's create the hook (if it not exists)
  24. $hook = new Hook();
  25. $hook->name = 'top_menu';
  26. $res = $hook->save();
  27. // return true on install succeed
  28. if ($res && parent::install())
  29. return true;
  30. return false;
  31. }
  32. public function uninstall()
  33. {
  34. // uninstall the module will uninstall the hook :)
  35. $hook = Hook::get('top_menu');
  36. $res = $hook->delete();
  37. // return true on uninstall succeed
  38. if ($res && parent::uninstall())
  39. return true;
  40. return false;
  41. }
  42. public function hookTop_Menu(){
  43. // of course, your theme contains {$TOP_MENU} somewhere !
  44.  
  45. // feel free to execute any code here
  46. $a = 1;$b = 2; $c = $a + $b;
  47.  
  48. global $smarty;
  49. // (you can use smarty)
  50. $smarty->assign('res', $c);
  51.  
  52. // or also simple echos (not recommended of course)
  53. echo "this will be displayed on pages containing {$TOP_MENU} (if I have good memories)";
  54. }
  55. }
Add Comment
Please, Sign In to add comment