replaceBlock()

replaceBlock() – Replaces an existing block with new content.

Synopsis

require_once 'HTML/Template/Sigma.php';

mixed HTML_Template_Sigma::replaceBlock ( string $block , string $template , boolean $keepContent = false )

Description

Replaces an existing block with new content. This function will replace a block of the template and all blocks contained in it and add a new block instead. This means you can dynamically change your template.

Sigma analyses the way you've nested blocks and knows which block belongs into another block. This nesting information helps to make the API short and simple. Replacing blocks does not only mean that Sigma has to update the nesting information (relatively time consuming task) but you have to make sure that you do not get confused due to the template change yourself.

Parameter

string $block

name of a block to replace

string $template

new content

boolean $keepContent

TRUE if the parsed contents of the block should be kept

Return value

return SIGMA_OK on success, error object on failure

Throws

Possible PEAR_Error values
Error code Error message Reason Solution
SIGMA_BLOCK_NOT_FOUND Cannot find block '$block' There is no block $block in the template Check the block name spelling, check whether you added all the necessary blocks to the template
SIGMA_BLOCK_DUPLICATE The name of a block must be unique within a template. Block 'blockname' found twice. The new block contains a subblock that has the same name as the existing one Check the $template and rename the block to something else
SIGMA_CALLBACK_SYNTAX_ERROR Cannot parse template function: (error description) Bogus syntax for template function parameters. Fix the template function definition, pay special attention to quoting rules.

Note

This function can not be called statically.

Checks whether the placeholder exists (Previous) Replaces an existing block with new content from a file. (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.