19/10/2011

How to : integrate wordpress menu into prestashop

Ouch :) This article was published 13 years ago - might be out of date, check out stuff or leave comment

The wordpress and prestashop integration is a big subject : prestashop is good for selling products and wordpress is good for dealing with content. One very efficient feature of wordpress is the menu builder that allows you to build unlimited hierachical menus. We submit here a technique that hooks into the wordpress update menu event to generate a static version of the modified menu each time the menu is modified. The generated file can be then included in your prestashop theme via easy static include. You build a sort of cache system for the hierarchical menu structure builder that comes with the wordpress system.

  1. create a cache directory in your wordpress theme folder
  2. add the following code to your functions.php file
  add_action("wp_update_nav_menu" , 'poleouestMakeMenu' );
  function poleouestMakeMenu($menuId)
  {
      $html=wp_nav_menu(array('menu'=>$menuId, "echo"=>false));
      $fileNAme= STYLESHEETPATH . "/cache/" . "menu" . $menuId .".html";
     
      file_put_contents($fileNAme,$html);
  }

once you've tested that the menu . html file is generated, include it in your prestashop template via some hack in the prestashop core. Let us know how you do it !!

To top