') ') Fork me on GitHub

Search

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $10.00
Net Balance: $9.41
Left to go: $90.59

Donations
Dante7237  ($10)Dec-3

Learn XOOPS Core

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

- 2 2.5 2.6 3.0 4 6 2013 Abuse Android AntiHarvesting AntiMalUser AntiSpam API Apple Battlefield Blocks Bootstrap By Captcha cell chronolabs Clicks content CĂN demo docek download Dresses evden eve facebook Fat Food for free Gateway giải Google Guide herre Home Honeypot Human HỘ IP iPhone jQuery Law Legal List Loss mobile module modules Monster new newbb news nhiệt NHÀ online PARK Payment phone PHP Prevention profile project Protector publisher Rapid release RESIDENCE responsive review Rights rmcommon security Sentry Signed site Smartphone Smoking Solution Spam Studio tags tdmcreate The Theme themes web weight Wishcraft xoops Xortify XPayment

New Users

Registering user

# 137911

mydarkglobe

Welcome to XOOPS!




Bottom   Previous Topic   Next Topic  |  Register To Post

« 1 (2) 3 »


#11 Posted on: 2012/3/13 4:13 Re: Trick [SMARTY] Compress your code HTML
Quote:
Quote:
Exactly would require that the compiled code is compressed before the file is saved in cache...

I saw in this article that:

Quote:
PrestaShop takes the hard work out of combining, compressing and caching CSS and JavaScript by doing it all for you. It has the option to combine all external CSS files into a single CSS file and all external JavaScript files into a single JavaScript file. There is an option to compress inline JavaScript in HTML too. PrestaShop uses Douglas Crockford's JSMin Javascript minified ported to PHP by Ryan Grove for its compression and Smarty to cache the combined, compressed file.

If somebody could implement it in XOOPS, it would be very cool

There is also this article with optimization tips.


For compress Smarty With the Plugin Saci. (Smarty Asset Compiler (sacy))
They explain how: here

I'll try to do an installation on SMARTY neutral. (No Xoops)




Top


Forum xoops
iLuc
Joined:
2009/6/5 19:46
From France
Group:
Registered Users
Posts: 37
(Show More) (Show Less)


#12 Posted on: 2012/3/13 4:18 Re: Trick [SMARTY] Compress your code HTML
Quote:
an follow that...but

is this the file scipt that one needs to download called Smarty-3.1.8. In this package there are 2 folders, one called libs and the other called demo
in the libs and in the libs folder there are more, plugings and sysplugins where the file outputfilter.trimwhitespace.php resides

do one needs to install this Smarty folder in the root system

Advise please


it's here ---> ../Smarty-3.1.8/libs/plugins/outputfilter.trimwhitespace.php

if it does not work is that it is the other smarty folder. (Other version).

You just have to copy paste codes.
Nothing more.

Top


Forum xoops
iLuc
Joined:
2009/6/5 19:46
From France
Group:
Registered Users
Posts: 37
(Show More) (Show Less)


#13 Posted on: 2012/3/13 5:03 Re: Trick [SMARTY] Compress your code HTML
I followed what you said and the end result is a blank white page. I am using xoops 2.4.5

Top


Be Set FREE!
rgauci
Joined:
2007/8/31 9:24
From Malta
Group:
Registered Users
Posts: 173
(Show More) (Show Less)


#14 Posted on: 2012/3/13 8:48 Re: Trick [SMARTY] Compress your code HTML
Upgrade Xoops.

Top


Forum xoops
iLuc
Joined:
2009/6/5 19:46
From France
Group:
Registered Users
Posts: 37
(Show More) (Show Less)


#15 Posted on: 2012/3/13 9:27 Re: Trick [SMARTY] Compress your code HTML
There was no need to upgrade xoops

I just changed this


$xoopsTpl =& $xoTheme->template;
$xoopsTpl->load_filter('output', 'trimwhitespace');

to this

$xoopsTpl =& $xoTheme->template;
$xoopsTpl->load_filter('outputfilter.trimwhitespace);

note the 'outputfilter.trimwhitespace'

and worked fine and fast I must say

thanks for all your work iLuc

Top


Be Set FREE!
rgauci
Joined:
2007/8/31 9:24
From Malta
Group:
Registered Users
Posts: 173
(Show More) (Show Less)


#16 Posted on: 2012/3/13 9:34 Re: Trick [SMARTY] Compress your code HTML
Great ! :)

It's good to know this trick.

$xoopsTpl =& $xoTheme->template;
$xoopsTpl->load_filter('outputfilter.trimwhitespace');


Top


Forum xoops
iLuc
Joined:
2009/6/5 19:46
From France
Group:
Registered Users
Posts: 37
(Show More) (Show Less)


#17 Posted on: 2012/11/3 13:40 Re: Trick [SMARTY] Compress your code HTML
Hi !!..

Another tip to improve. :)

You disable the solution above.
(Only for those who have set up)
$xoopsTpl->load_filter('outputfilter.trimwhitespace');


The trick that I propose is more interesting. ;)
And easy to implement.

It allows compressed code directly in the files in place.
Therefore, the compression is done "before" saving the file cached.

The previous solution was performing compression (Minify Html) when displaying pages.

The solution that I propose to you now, it will compress the code, when creating the file it is cached.
/xoops_data/caches/smarty_cache/your-file-cache.html.php
/xoops_data/caches/smarty_compile/your-file-cache.html.php

How?
it is very simple.

in folder : /class/smarty/

Open file : Smarty_Compiler.class.php

Add in line 424

Just before this code:

$compiled_content $template_header $compiled_content;
        return 
true;
    }


Add this code:

/*************** HACK iLUC Minify HTML / COMPRESS CODE *******************/
        
$compiled_content trim(preg_replace('/((?<!?>)n)[s]+/m''1'$compiled_content));
        
$compiled_content preg_replace('#<!--//.*?-->#s'''$compiled_content);
           
$compiled_content preg_replace("/(rn|n|r)/"""$compiled_content);
           
$compiled_content str_replace(CHR(13).CHR(10),"",$compiled_content);
           
$compiled_content preg_replace("/(nn|nnn)/"""$compiled_content);
           
$compiled_content preg_replace("#>(s+)<#s""><"$compiled_content);


At the end, you must have the following:

[...]
if ($this->_init_smarty_vars) {
            $template_header .= "<?php require_once(SMARTY_CORE_DIR 'core.assign_smarty_interface.php');nsmarty_core_assign_smarty_interface(null$this); ?>n";
            $this->_init_smarty_vars = false;
        }

/*************** HACK iLUC Minify HTML / COMPRESS CODE *******************/
        $compiled_content = trim(preg_replace('/((?<!?>)n)[s]+/m', '1', $compiled_content));
        $compiled_content = preg_replace('#<!--//.*?-->#s', '', $compiled_content);
           $compiled_content = preg_replace("/(rn|n|r)/", "", $compiled_content);
           $compiled_content = str_replace(CHR(13).CHR(10),"",$compiled_content);
           $compiled_content = preg_replace("/(nn|nnn)/", "", $compiled_content);
           $compiled_content = preg_replace("#>(s+)<#s", "><", $compiled_content);

        $compiled_content = $template_header . $compiled_content;
        return true;
    }

[...]



Your compress code is Active !! and even better!



Top

iLuc
Joined:
2009/6/5 19:46
From France
Group:
Registered Users
Posts: 37
(Show More) (Show Less)


#18 Posted on: 2012/11/3 13:55 Re: Trick [SMARTY] Compress your code HTML
To verify that it works.
Open a file cache.

The code should be like this:
- No white space
- No newline

<?php /* Smarty version 2.6.26, created on 2012-11-03 19:50:48
         compiled from /homez.9/disquesvb/www/modules/system/themes/default/xotpl/xo_footer.html */ 
?>
<?php 
require_once(SMARTY_CORE_DIR 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier''date_format''//www/modules/system/themes/default/xotpl/xo_footer.html'2false),)), $this); ?>
<div id='xo-footer'><div id="xo-footer-body">Powered by <a class="tooltip" rel="external" href="http://sourceforge.net/projects/xoops/" title="Xoops Project"><?php echo $this->_tpl_vars['xoops_version']; ?></a> &copy; 2001-<?php echo ((is_array($_tmp=time())) ? $this->_run_mod_handler('date_format'true$_tmp"%Y") : smarty_modifier_date_format($_tmp"%Y")); ?></div><div id="xo-footer-rss" ><a class="tooltip" rel="external" href="<?php echo 'http://www.disques-vinyles.fr/backend.php'?>" title="<?php echo @_OXYGEN_RSS?>"><img src="<?php echo 'http://www.disques-vinyles.fr/modules/system/themes/default/img/feed.png'?>" /></a></div><div><?php $this->_smarty_include(array('smarty_include_tpl_file' => ($this->_tpl_vars['theme_tpl'])."/xo_uptop.html"'smarty_include_vars' => array()));?></div></div>


Top

iLuc
Joined:
2009/6/5 19:46
From France
Group:
Registered Users
Posts: 37
(Show More) (Show Less)


#19 Posted on: 2012/11/5 10:56 Re: Trick [SMARTY] Compress your code HTML
Thanks for the tip, but i see lot of code changes and im now confused

Is it possible to upload the modified files header.php and outputfilter.trimwhitespace.php so that anyone who want to use this hack only have to upload it to there website ?

Top

Yurdal
Joined:
2005/3/27 13:59
Group:
Registered Users
Posts: 264
(Show More) (Show Less)


#20 Posted on: 2012/11/6 3:58 Re: Trick [SMARTY] Compress your code HTML
Hi Yurdal,

I use this trick on this site.
http://www.disques-vinyles.fr

And also on another site that uses Smarty.
http://www.annuaire.avisduweb.fr ( No Xoops, this is a Web Directory )

But the change is the same, the same file:
Smarty_Compiler.class.php

I disabled for that one line of code, due to an Ajax script.
So the code is left aligned. That is fine too.

I advise you to use the second tip, not the one with:
outputfilter.trimwhitespace.php

The two can work together, but it is useless, the display will prompt more work. The second solution I propose is more effective.

You use any version of Xoops?

Luc



Top

iLuc
Joined:
2009/6/5 19:46
From France
Group:
Registered Users
Posts: 37
(Show More) (Show Less)




« 1 (2) 3 »



You cannot view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create pdf.
You cannot get print page.

[Advanced Search]