GetSimple Support Forum
Processing whole page content before output - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: Processing whole page content before output (/showthread.php?tid=1884)



Processing whole page content before output - bogyvet - 2011-06-26

During Affiliate Product Manager Plugin I face with one problem. I want page content xhtml code to have proper indentation or to be all in one line. But I can not figure how to process complete page code before output.

I realize that :

Quote:exec_action('index-posttemplate');

Do final work but I can not find where this function exists.


Processing whole page content before output - Carlos - 2011-06-27

'index-posttemplate' hook is fired *after* the page is rendered. If you want to alter the page content before it is displayed, you'll probably need to use the 'content' filter: see http://get-simple.info/wiki/plugins:hooks_filters#core_filters


Processing whole page content before output - bogyvet - 2011-06-27

I do not know what is problem I try:

Quote:add_filter('content','xhtml_one_line');

and function:

Quote:function xhtml_one_line($contents){

$temp = $contents;
$temp = preg_replace('/^\s+|\n|\r|\s+$/m', '', $temp);
$temp = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $temp);
$temp = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $temp);
$temp = preg_replace(array('(( )+{)','({( )+)'), '{', $temp);
$temp = preg_replace(array('(( )+})','(}( )+)','(;( )*})'), '}', $temp);
$temp = preg_replace(array('(;( )+)','(( )+Wink'), ';', $temp);
$temp = preg_replace(array('(Sad )+)','(( )+Smile'), ':', $temp);
$temp = preg_replace('/(\s|)\,(\s|)/', ',', $temp);

return $temp;
}

But I do not see results for some reason, GSDEBUG enabled. No errors.


Processing whole page content before output - polyfragmented - 2011-06-27

It's $content I believe, not $contents.


Processing whole page content before output - bogyvet - 2011-06-27

It doesn't make difference I look at Plugins that do more less same like Replacer and External commenting. They use this naming for function.


Processing whole page content before output - Carlos - 2011-06-28

bogyvet Wrote:I do not know what is problem I try:

I've tried a simpler test, code based on yours:
Code:
add_filter('content','stoz');
Code:
function stoz($contents){
            $temp = $contents;
            $temp = str_replace('s', 'z', $temp);
            return $temp;
    }

Thiz workz. :-)

So it may be something wrong in your str_replace or preg_replace lines. (No idea what, I haven't examined them...)


Processing whole page content before output - Carlos - 2011-06-28

I've tried your code again. I don't know if it does all you expected, but looking at the page source, the page content is stuffed in just one line. So it does something.


Processing whole page content before output - bogyvet - 2011-06-29

Thanks I will try another installation!!!