farbfinal home · jFinalizer · jFinalizer technotes

jFinalizer developer notes

for joomla! component developers

jfinalizer logo

Introduction

Using jFinalizer while developing components, modules or plugins can be quite helpful to see what HTML output could look like after working through jFinalizer. Also, you can verify CSS / JS processing for your clients. This document gives a brief overview on how to implement jFinalizer during your application design workflow.

Working with HTML compression

Its a great idea to verify that your component works properly with jFinalizer HTML output compression. Currently, we encourage developers to get Components working with at least Safe Mode C compression level.

What usually influences correct rendering after jFinalizer HTML processing are HTML linebreaks and whitespaces. For example, processing Safe Mode C will reduce all necessary HTML whitespaces, although some browsers might eventually render them if present. So make sure to properly output whitespaces if they are between line breaks or opening / closing tags.  For example this 2-line-statement

 <a href="#link1">link1</a>
<a href="#link2">link2</a>

would cause most browsers to render

link1 link2

but after line break removal it would show as

link1link2

So if you require correct whitespaces between line breaks, its always a good idea to append &nbsp; or put both statements on one line with a whitespace.

jFinalizer API tools

jFinalizer exposes itself into the joomla! mainframe when running, so you can check if jFinalizer is installed, running and processes HTML. If you cannot get your output render properly, there are tool functions to wrap a bypass around HTML or JavaScript blocks. But please note that this should be the last choice after trying to optimize your content.

First of all, jFinalizer linkes an instance to itself to the joomla mainframe, so you can check if its installed / running:

$mainframe->jFinalizer;

These public methods are available starting from jFinalizer 1.0.11:

jFinalizer->doHTML()
Return bool true if jFinalizer is running and processing HTML. Example:

$mainframe=JFactory::getApplication(); 
if (@$mainframe->jFinalizer->doHTML()) echo "yap, jFinalizer runs";

jFinalizer->startProtect();
start a protected area. This Area will not be HTML processed.

jFinalizer->endProtect();
close a protected area. This Area will not be HTML processed.

example:

$mainframe=JFactory::getApplication(); 
echo $mainframe->jFinalizer->startProtect();
echo "My Protected content goes here with all     Whitespaces, linebreaks etc";
echo $mainframe->jFinalizer->endProtect();

jFinalizer->protect(string $Inputdata);
The better method: enclose input data string with protection, return string. This area will not be HTML processed. If jFinalizer is not active or HTML processing is disabled, the original string is returned.

For example, you can check if jFinalizer is installed / running and write a wrapper function like this to make sure everything it output without processing, no matter if jFinalizer is installed, runs or not:

 $mainframe = JFactory::getApplication();
if (isset($mainframe->jFinalizer)) {
 function wrap ($input){
 global $mainframe;
 return $mainframe->jFinalizer->protect($input); 
 }
} else  {
 function wrap ($input){
 return $input;
 }
}
echo wrap("my protected content");

tech notes

joomla system events

jFinalizer hooks into the joomla system trigger onAfterRender and onAfterInitialize. All actual processing is done in onAfterRender.

what jFinalizer knows about content

Absolutely nothing. jFinalizer has no idea whats going on at the page. It simply processes HTML. However, jFinalizer checks if the system.cache plugin is running, so HTML processed content can be stored into cache. Unfortunately, there is no joomla! hook for caching, so jFinalizer hooks into system::onAfterInitialize, checks if system.cache is active and forces a re-trigger of system.cache's onAfterRender function after jFinalizer has compressed the content.

Road Map

  • include Developer Mode for direct access to HTML compression features
  • joomla 1.6 native support
  • change system.cache implementation with joomla 1.6

 

Comments & Bug Reports

When posting a bug report or problem, don't forget to post the jFinalizer version. If you use HTML compression, tell us what Mode you use.

 

Add comment


Security code
Refresh

(c) FARBFINAL 2010. JFINALIZER IS LICENCED GPL - HOME