Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Smarty.php Mod to Remove all UN-NECESSARY White Space

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 06-04-2004, 09:40 PM
 
Adian009 Adian009 is offline
 

Advanced Member
  
Join Date: Mar 2004
Location: Tiverton, RI, USA
Posts: 37
 

Default Smarty.php Mod to Remove all UN-NECESSARY White Space

Smarty has an included filter that you can implement quite simply by adding one line of code to your SMARTY.PHP file.

Add the following line to the file just below the ImagesDir and SkinDir assign statements near the end:

Code:
$smarty->load_filter("output","trimwhitespace");

It safely removes all whitespace from the generated HTML just prior to sending the page to the client - increases speed dramatically by reducing the overall size of the file. It works great and you will have no more un-necessary blank lines or spaces.

Check it out before and after by using View, Source in your browser on any X-Cart page - the difference is easily noticable.

Al Ponte
__________________
---------------------------------------------
Infosolv, LLC
A Professional Services Company
X-Cart v3.5.10 & 4.01
Find our MOD\'s at: Custom X-Cart MOD\'s, Add-On\'s & X-Cart Hosting!
Reply With Quote
  #2  
Old 06-05-2004, 04:56 AM
  TelaFirma's Avatar 
TelaFirma TelaFirma is offline
 

X-Adept
  
Join Date: Nov 2002
Location: North Carolina USA
Posts: 930
 

Default

Have you tested this will all the JavaScript that is in X-Cart? Some JS does not function wel after removing whitespace....
Reply With Quote
  #3  
Old 06-05-2004, 05:01 AM
  TelaFirma's Avatar 
TelaFirma TelaFirma is offline
 

X-Adept
  
Join Date: Nov 2002
Location: North Carolina USA
Posts: 930
 

Default

Ok... I see... it is actually leaving the Javascript alone. Much different than {strip} tags. Interesting....
Reply With Quote
  #4  
Old 06-08-2004, 12:42 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Nifty trick, tested it with 3.5.x works like a charm. You know what version this was added to smarty
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #5  
Old 06-10-2004, 07:42 PM
 
FX FX is offline
 

Member
  
Join Date: May 2004
Location: US
Posts: 12
 

Default

Thanks Adian009,
Works great in 3.5.8! Before I had 417 lines of code in one of my pages, now I have 404
I was looking for this function, even wanted to use external editor.
Reply With Quote
  #6  
Old 06-10-2004, 11:37 PM
  carlisleglass's Avatar 
carlisleglass carlisleglass is offline
 

eXpert
  
Join Date: Aug 2003
Location: Carlisle, UK
Posts: 316
 

Default

Very good discovery !! Its speeded up my site
__________________
Darren Kierman
Carlisle Glass (http://www.carlisleglass.co.uk/)
... running X-Cart Gold 4.4.5 [unix]
Reply With Quote
  #7  
Old 06-11-2004, 03:28 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default

Did anyone find that it stripped out the spaces in the e-mail templates too?
Reply With Quote
  #8  
Old 06-12-2004, 09:28 AM
 
NuAlpha NuAlpha is offline
 

X-Adept
  
Join Date: Aug 2003
Location: US
Posts: 598
 

Default

Quote:
Originally Posted by PhilJ
Did anyone find that it stripped out the spaces in the e-mail templates too?

Anyone know if there is a way to prevent this by perhaps putting certain tags in the email templates that prevent them from having the spaces stripped out?

One problem I found with using {strip} tags is that two Smarty tags with a space between them will be butted up against each other, and so to maintain the spacing I had to put "" between them.

Does this problem happen with this Smarty modification?
__________________
X-Cart Pro 4.5.5 Platinum
X-Payments 1.0.6
PHP 5.3.14
MySQL 5.1.68
Apache 2.2.23
Reply With Quote
  #9  
Old 06-12-2004, 02:57 PM
 
Adian009 Adian009 is offline
 

Advanced Member
  
Join Date: Mar 2004
Location: Tiverton, RI, USA
Posts: 37
 

Default Replies to All

Well, you use {literal}{/literal} with JavaScript and it won't be touched. I have been using this for 3 months without issue.

This will only strip whitespace from templates being sent to a client - not email as far as I know.

--al
__________________
---------------------------------------------
Infosolv, LLC
A Professional Services Company
X-Cart v3.5.10 & 4.01
Find our MOD\'s at: Custom X-Cart MOD\'s, Add-On\'s & X-Cart Hosting!
Reply With Quote
  #10  
Old 06-12-2004, 07:42 PM
 
NuAlpha NuAlpha is offline
 

X-Adept
  
Join Date: Aug 2003
Location: US
Posts: 598
 

Default

Some email templates are used for display in the browser.

I guess I will just stick with adding {strip} tags to various documents until I get this worked out.
__________________
X-Cart Pro 4.5.5 Platinum
X-Payments 1.0.6
PHP 5.3.14
MySQL 5.1.68
Apache 2.2.23
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:57 PM.

   

 
X-Cart forums © 2001-2020