View Full Version : CSS Menu

02-06-2007, 07:11 PM
This is a great contribution, the only css menu contrib that I actually liked. However, I noticed something disturbing about it. If you install Chemo's amazing queries debug contribution, to find out how many mysql queries are being made in each page refresh (on each page of your entire site, thus lowering the page load speed) you will notice that the queries, with this css menu installed, are well over 2000! (Well, I noticed that anyway, you might be lucky and have less or unlucky and have more). Just to give perspective, the stock osc files and original category menu will give you about 100 queries, at the most, and that is a BIG difference in page loading times. And if you are running off of a shared server, that is just a big no-no. This will bog down your server if you get a lot of page hits, because on each page, there are thousands of queries being performed, just for the menu. They do not cost a lot of time, because even with the menu taking up about 2500 queries, my index.php was still loading up in about 4 seconds. However, I got it down to about 1 second by adding some little fixes to the categories_css.php file. And if you add up all the seconds a potential customer will save by you doing this, from arriving on your page and potentially making a purchase (assuming the slow page loads doesn't make him leave) it will be an enormous improvement.

If you want to see what it should be, search the contributions for "queries debug" and install it. Check at the very bottom of the page on your index.php and see how many queries you have. Then go back to the stock osc category menu in catalog/includes/column_left.php by changing categories_css.php with categories.php wherever it shows up. Then check again, and you will see what I mean (of course, if for some reason this strange occurance doesn't happen to you, consider yourself lucky!).

Now, I am NOT a php programmer, I understand the very basics of it only. I have, though, done a VERY rough edit of the categories_css.php file to remove some of the "counts" that were being queried. It appeared that even though in the Admin-> Configurations-> Category Count, I had it turned off, this menu was trying to still count all of the different products in the categories. So by commenting out some lines, I was able to get the queries reduced to about 10% of the original. Now, this works for me, I don't know if it will for you, so please backup before you try this. And unless you know exactly what you're doing, don't comment out any more lines in the file! This might delete the ability of the menu to display subcategories, or might stop it from working altogether. So, I have included the most updated css menu contribution, released on Nov. 20, 2006, except for the patch below by micr, so if you need that, you will have to do that separately.



Backup your catalog/includes/boxes/categories_css.php and replace it with the one I have packaged with the original contribution. Look in my archive for a folder called "my file". You will have to change the style to match what you already have, but you can do that by just highlighting the style section of your file and replacing the new one; nothing there has changed so you will not run into problems.


Unzip my archive, and you will see a "my file" folder. That includes my edited file, don't worry about that yet. You will also see an archive called css_menu_0_3.zip. unzip that and install it like normal. And then go my "my file" and replace catalog/includes/boxes/categories_css.php with mine and change the style section to match your site accordingly.

Now, this is just a hack of this contribution to get it to load faster. I'm sure someone with better php skills can make this look nicer in the future, so here's looking forward to someone stepping up and making this contribution better. Direct any thanks to the guys who have made this contribution and worked on it, they deserve it.

Again, if you want to see what type of difference we're talking about, go back to your original categories.php menu like I mentioned above and see how many database queries you have with that one. If it's a lot lower, then try what I said above and hopefully that will help your site out a lot. Good luck.

More... (http://www.oscommerce.com/community/contributions,4589)

05-01-2007, 03:40 PM
where is this added to the BTS template. I see no documentation here or in the contrib forum.

05-06-2007, 08:41 PM
This mod is not for osCMax, it is for standard osCommerce, that is why you will not find any mention of BTS, as that is not in standard osCommerce.