da tradurre

Output Handling

Introduction

Using PHP output-buffering-functions, all output is cached until the parsing of the whole script is done or the script forces the cached output to be displayed. The great thing is that one can manipulate the output prior to sending it like a normal string. PHP-Fusion always used output buffering to enable painless cookie creation. With PHP-Fusion 7, the benefits of output buffering are utilized far more.

With Output Handling, it is possible to change the site title or add head tags from within panels, infusions or pages and thus after the header was actually already parsed. The new theme System of PHP-Fusion 7 also relies strongly on output buffering to provide a template-like full-page layout.

For other purposes, a new output_handling_include.php was introduced. It contains functions to add head tags, change the site title and change any string in the cached output. When one of the functions is called, the changes are recorded and applied to the buffered output just before it is sent to the browser.

Output Handling Functions

set_title

set_title(string $title)

This function will replace the title by the one specified by the $title argument.

add_to_title

add_to_title(string $addition)

This function will add the $addition argument to the existing site title.

set_meta

set_meta(string $name[, string $content])

This function will replace the $name meta tag's content by the one specified by the $content argument.

add_to_meta

add_to_meta(string $name, string $addition)

This function will add the $addition argument to the existing $name meta tag's content.

add_to_head

add_to_head(string $tag)

This function will add the $tag argument between the site's <head>-tags, just before </head>.

replace_in_output()

replace_in_output(string $target, string $replace, string $modifiers)

With this function, you can replace any string in the output using a regular expression replacement. The function will construct a preg_replace() function call from the parameters like this: $output = preg_replace(“^$target^$modifiers”, $replace, $output);

handle_output()

handle_output(string $output)

This is the function that will apply the changes that were requested using the functions listed above. Do not call this function! It will be called in footer.php as the last step before sending the output to the browser.

 
temi/output_handling.txt · Ultima modifica: 2008/08/21 14:55 da lelebart
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki