The menu is created dynamically from the data inserted in the database earlier. But each time the website displays the menu it need to query the database, fetch the result and create the markup over and over again. This leads to a slower page load. Here comes the utility of caching. Generally the main menu is not changed frequently. So the HTML created by PHP may be saved in server and served to the client without any dynamic rebuilding. This will speed up page load time. After a predefined frequency the cache will be rebuilt automatically. Thus the change made to the database will be reflected in the main menu. The attached version of the menu is caching enabled. Test the difference between the previous version (http://layzend.info/2011/06/20/multi-level-category-management-part-3/) where caching is not enabled.
We have already solved the main problem of adding, editing, deleting multilevel categories into a database table. Now when we have a lot of data in the table, we must show them in a multilevel fashion also. Here is a solve for this thing. I have used the beautiful jQuery apycom menu. The calling of the function is very straight forward. Include the new “lzmlm.php” file shared with this post. Visit http://apycom.com where you can get a lot of beautiful menu. Download the menu of your choice and extract the zip file inside “js/jquery/plugins”. Include “menu.js” and “menu.css” in your current file where you want to place the menu. Now call the following function to render the menu in your desired position.
echo apycomMenu()
