« 1 (2) 3 »
iLuc iLuc
  • Just popping in
  • Just popping in
  • Joined: 2009/6/5 20:46
  • From France
  • Group: Registered Users
  • Posts: 47
  • Posted on: 2012/3/13 5:13
Re: Trick [SMARTY] Compress your code HTML #11
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)


iLuc iLuc
  • Just popping in
  • Just popping in
  • Joined: 2009/6/5 20:46
  • From France
  • Group: Registered Users
  • Posts: 47
  • Posted on: 2012/3/13 5:18
Re: Trick [SMARTY] Compress your code HTML #12
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.
rgauci rgauci
  • Not too shy to talk
  • Not too shy to talk
  • Joined: 2007/8/31 10:24
  • From Malta
  • Group: Registered Users
  • Posts: 173
  • Posted on: 2012/3/13 6:03
Re: Trick [SMARTY] Compress your code HTML #13
I followed what you said and the end result is a blank white page. I am using xoops 2.4.5
Be Set FREE!
iLuc iLuc
  • Just popping in
  • Just popping in
  • Joined: 2009/6/5 20:46
  • From France
  • Group: Registered Users
  • Posts: 47
  • Posted on: 2012/3/13 9:48
Re: Trick [SMARTY] Compress your code HTML #14
Upgrade Xoops.
rgauci rgauci
  • Not too shy to talk
  • Not too shy to talk
  • Joined: 2007/8/31 10:24
  • From Malta
  • Group: Registered Users
  • Posts: 173
  • Posted on: 2012/3/13 10:27
Re: Trick [SMARTY] Compress your code HTML #15
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
Be Set FREE!
iLuc iLuc
  • Just popping in
  • Just popping in
  • Joined: 2009/6/5 20:46
  • From France
  • Group: Registered Users
  • Posts: 47
  • Posted on: 2012/3/13 10:34
Re: Trick [SMARTY] Compress your code HTML #16
Great ! :)

It's good to know this trick.

$xoopsTpl =& $xoTheme->template;
$xoopsTpl->load_filter('outputfilter.trimwhitespace');
iLuc iLuc
  • Just popping in
  • Just popping in
  • Joined: 2009/6/5 20:46
  • From France
  • Group: Registered Users
  • Posts: 47
  • Posted on: 2012/11/3 14:40
Re: Trick [SMARTY] Compress your code HTML #17
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!

iLuc iLuc
  • Just popping in
  • Just popping in
  • Joined: 2009/6/5 20:46
  • From France
  • Group: Registered Users
  • Posts: 47
  • Posted on: 2012/11/3 14:55
Re: Trick [SMARTY] Compress your code HTML #18
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>
Yurdal Yurdal
  • Friend of XOOPS
  • Friend of XOOPS
  • Joined: 2005/3/27 14:59
  • Group: Registered Users
  • Posts: 306
  • Posted on: 2012/11/5 11:56
Re: Trick [SMARTY] Compress your code HTML #19
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 ?
iLuc iLuc
  • Just popping in
  • Just popping in
  • Joined: 2009/6/5 20:46
  • From France
  • Group: Registered Users
  • Posts: 47
  • Posted on: 2012/11/6 4:58
Re: Trick [SMARTY] Compress your code HTML #20
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

How to effectively post a question in the Xoops forums? - Read here...
Design by: XOOPS UI/UX Team