7.2. Opt_View class
7.2.19. getOutputBuffers()
7.2.18. getGlobal()
« Previous
7.2.20. getTemplate()
Next »

7.2.19. getOutputBuffers()

ConstructMethod
Visibilitypublic
Referencearray getOutputBuffers()
Returned valueThe static parts of the template.
Versionssince 2.0.1

This method is used in the caching systems to support the opt:dynamic tag in the cached views. It returns the list of cached parts of the executed template, except the last one which must be closed manually.

The dynamic part of the cached template is saved by the compiler in the file with the .dyn extension in the compilation directory. It is a serialized array of PHP code snippets which should be mingled with the static data returned by this method. Below, you can see a sample mingling algorithm:

if($view->hasDynamicContent())
{
    $list = $view->getOutputBuffers();
    $dynamic = unserialize(file_get_contents($tpl->compileDir.$view->_convert($view->getTemplate()).'.dyn'));
 
    $output = '';
 
    for($i = 0; $i < sizeof($list); $i++)
    {
        $output .= $list[$i].'<'.'?php '.$dynamic[$i].' ?>';
    }
    $output .= ob_get_flush();
}

In order to get the content of the last buffer, you must use ob_get_flush(), as the returned code must also appear in the browser.

See also:

7.2.19. getOutputBuffers()
7.2. Opt_View class
« Previous
7.2.18. getGlobal()
Next »
7.2.20. getTemplate()