HTML Catalog Cleaner - Removes excess white space
This script acts like a one time {strip} tag, removing all unnecessary white spaces from your .html files generated by the HTML Catalog, thus reducing the bandwidth needed for these files.
At the moment, I don't have a .tpl interface written for it, so you have to call it from your browser. This works on your existing catalog, though I am sure you could pull out the regex code and stick it into admin/html_catalog.php if your so inclined. Here is the code. Put it in whatever directory you wish under whatever name you wish (.php extension of course)... Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Let me know if you find any problems! :) |
Code:
# Initialize variables. I'm testing now! :-) |
The code is cleaned up although the reported initial and finished file size for the work is the same.
Pages are lightning quick. This is a SICK SICK mod. I love it. I just added it as a link under my HTML Catalog link in the menu admin. skin1/admin/menu_admin.tpl |
Quote:
I had already done the once over with this mod on our catalog, when at the last second I decided to add the 'filesize difference' code before posting so I never even saw the output. :lol: I am suprised that there was no difference in filesize. :? I wonder why not....hmmm. :?: |
By the way adpboss, did you make use of those regular expressions I posted for adding {literal} tags to every space and newline in your plain text emails? I have not gotten a chance to actually test it, but I will be doing so soon as I need plain text labels to print.
Am thinking about writing a customizable mod to allow printing on sheets of Avery style labels. |
Found a bug, it kills this javascript that I have in my product pages that pops up a new window for detailed images.
So I can't use it as-is, but hopefully I'll find time to play with this and get it to work. :( Is there a way to PREVENT areas of code from being touched? Code:
{literal} |
Hmmm...I will have to think about this one. Forgot about the javascript. :(
|
Here is the revised version. This should take care of the javascript problem. :)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
Script still kills Javascript and hangs.
I ran it four times tonight and everytime it ran for more than 15 minutes when eventually I had to stop it. :( |
I am going to be redoing our HTML catalog soon. I will have to work on it then. :?
Not sure what is wrong though. |
All fixed! Tested it and it preserves the javascript while stripping the HTML. Doesn't hang anymore on my setup...which was the result of a stupid coding mistake. :P
Code:
<?php ini_set('zlib.output_compression', 'Off'); // Turn off zlib compression, if On, to prevent Mozilla output problems. ?> Let me know if you notice anything else that needs fixing. Enjoy! |
I'll test soon.
Thanks NuAlpha, it's a great mod if we get it working right. :) |
Minor update:
Replace the code: Code:
# Pad with 256 bytes for Internet Explorer to show output immediately. ...with: Code:
# Pad with 256 bytes for Internet Explorer to show output immediately. :wink: |
Potential bug that needs fixing...
Replace: Code:
<?php ini_set('zlib.output_compression', 'Off'); // Turn off zlib compression, if On, to prevent Mozilla output problems. ?> With: Code:
<?php That terminating PHP tag on the same line as the comment can cause problems. |
Just ran this on our latest HTML catalog. Stripped a total of 14,606,179 excess white spaces from all of the catalog files. Javascript was left untouched and everything seems to work great! 8)
|
Works with my java pop stuff, it's relatively fast and the script terminates properly with the report at the end.
This includes all of the bug fixes and updates up to the time of this post. Using version 3.4.14. GREAT JOB NUALPHA! Code:
<?php |
Anyone wanna tell me why I am getting this error? The only thing I have changed is my directory path???
Quote:
|
never mind, i figured it out, and with a total of 1,111,686 excess white spaces removed from my code.
wow, cudos bro, much appreciated mod, hope i can pay ya back later... |
Quote:
Welcome! :wink: |
Quote:
Hi jburba2000, I hit the same problem and wonder if you could let me know how you fixed it. Thanks. |
Same problem here in 3.5.10...parse error line2.....If you take take out the lines:
<?php б═ б═ini_set('zlib.output_compression', 'Off'); // Turn off zlib compression, if On, to prevent Mozilla output problems. ?> It gives a parse error on line 44....any ideas? |
Smarty has this built-in ;)
Code:
$smarty->load_filter('output','trimwhitespace'); :arrow: http://smarty.incutio.com/?page=SmartyTips |
Quote:
Yep, but it doesn't clear out the white spaces in the HTML catalog. It also won't remove all excess white space just multiples of the same kind. All of our templates are enclosed ing {strip} tags and our pages download as one long line of code. Remove the tags and turn on that output filter, and the code remains multi-line. As for the problem people are having here with the code I posted, I haven't a clue what could be wrong as I verified the code in Zend Studio and everything checks out fine. The one I have is the same version and runs just fine. :-k |
I figured it out. The problem is that when you copy the file there is a lot of white space before some lines. Take out all of that space, and the code works great. Awesome mod. It stripped 391,200 white spaces from my catalog :-)
-Bradley |
Will this mod have any affect on Google spidering (positive or negative?)
-Bradley |
Quote:
Positive in that the pages will download somewhat faster. Other than that I do not know. :) |
Compatibal with 4.0.6?
Will this work with 4.0.6?
|
I'm gonna' try it on 4.06 (nice job!) 8O
|
X-Cart Version 3.5.4
Mod is very sick! Worked like a clock! Here's the data: ----------------------------------------------------- There were 82,069 successful cleanings and 1 failures out of a total of 82,070 files. Your HTML Catalog files had a total combined length of 2,500,312,154 characters. They now have a total length of 2,009,804,777 characters. That is a total of 490,507,377 excess white spaces removed from your files. ----------------------------------------------------- Never mind the failure - it was garbage in the database. Anyone had more whitespaces removed than I have? Metal-X |
Works like a charm! Nice one! :D
|
GM,
Could you post your 4.0 code for us please? |
Quote:
So tell me, I see your on vs 4.0.9 now. What did you do to the code to make it work for this version? Will ADP's last post with all of the corrections made do the trick, or is there more to it than that? Thanks in advance for the help. :wink: |
I never changed the original code (NuAlpha revised version) XCart v4.09 and my sight is smokin' ! I'm on a shared server too.But I also applied Boomers Smarty Mod for the flipover.
This is the mod of the year man! 8O Well.... that's not all... I trimmed out the tags in home.tpl, trashed fancy cats, optimized my graphics, souped up the head.tpl...etc. (Nice Holley four barrel pumper...) |
And to think, shortly after writing this mod we decided using the HTML catalog was not feasible because of the number of product pages we have. Had to write some complex PHP and MySQL code distributed throughout Xcart to tie in precisely with mod_rewrite code. It all worked so well (after many migraine related bug fixes) our HTML catalog has since been deleted. :lol:
The only time this code became a server drain was when the Pompos/dir.com search engine bot brutalized our site, sucking more pages per minute than MSN, Google, Google-Media, Froogle, Yahoo, Teoma, etc. combined. They have since been banned. |
Quote:
In my cart, I have a few scripts that did not work with the literal tags, so I removed them and they worked. I noticed ADP had a complaint about the script issues up front and then there was a bit of tweaking going on, but if I remember, in the thread I thought I saw a mention of the use of literal tags to keep it working. With my inability to add the literal tags on the few scripts that didn't work until they were removed, will this Mod work for me without damage to the scripts? Thanks for the input, I appreciate it. |
Path Issues in php script
Hi NuAlpha
Thanks for the post - it looks good. I'm having problems with setting the absolute path in the Defining Constants. My site has the following structure to the catalog: http://www.eotr.com/Light4Life/catalog I have created the .php file and put it into the directory, but it keeps complaining about the "is not a directory! Please check the path and try again." for all the path methods I have used so far. Do we need to set special permissions for the php script and the html files? I have 1200 files with average size of 200Kbytes each. It would be interesting to see what it does to them :D Regards Ing. Stephen Hatton :idea: |
Re: Path Issues in php script
Quote:
You have to enter the absolute file path from root. For instance, most setups would look like-> "/home/user-dir-name/public_html/Light4Life/catalog" Don't include your domain name or http:// with that directory path. Your absolute file path should start with forward slash, which is root-> "/" Quote:
Permissions for the catalog directory should be chmod 777. |
Quote:
The mod I posted is only supposed to be used on the HTML catalog that you generate through Xcart. |
Quote:
Yes I understand that, yet the javascripts I am refering to are based in the customer home.tpl, where this is used to generate those HTML cat pages. So, when the catalog generation has been completed, and this mod has run to remove white spaces, the code embedded in the html pages, will it be damaged? Thanks for the reply |
Quote:
If you are refering to the javascript being damaged by striping the whitespaces, then no that code won't be damaged. The javascript is accounted for and allowed to have extra whitespaces. As for any other non-javascript code encased in {literal} tags, there is no way to prevent spaces from being striped as they are written purely as HTML once the catalog has run, not in Smarty template form. Is this what you were refering to? Sorry if I over/under explained myself. |
All times are GMT -8. The time now is 10:30 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.