[Wiki] created: Doc/Dev/BufferH4

Michael Slusarz <[email protected]>
Newsgroups gmane.comp.horde.cvs
Message-ID <[email protected]>
slusarz  Tue, 13 Apr 2010 19:06:57 -0400

Created page: http://wiki.horde.org/Doc/Dev/BufferH4

++ Output Buffering (H4)

Normally in PHP, one could wrap code in {{ob_start()}} and  
{{ob_get_clean()}} to grab output meant for the browser.   
Unfortunately, it is not so easy in the Horde framework since CSS  
stylesheet and JS output must not be sent until the page is entirely  
ready to output to the browser.

Therefore, it is necessary to use the Horde utility functions  
{{Horde::startBuffer()}} and {{Horde::endBuffer()}} to do output  
buffering.  Example:

<code type="php">Horde::startBuffer();
$notification->notify(array('listeners' => 'status'));
$notify_output = Horde::endBuffer();
</code>

In the above example, the status notifications may do things like add  
javascript files to the output buffer.  By using  
startBuffer()/endBuffer(), this guarantees that these javascript files  
will not be output to the browser and will instead properly be  
displayed when the page header is eventually created (normally  
{{templates/common-header.inc}}).


-- 
To unsubscribe, mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.