addBlock()

addBlock() -- Adds a block to the template

Synopsis

require_once 'HTML/Template/Sigma.php';

mixed HTML_Template_Sigma::addBlock (string $placeholder, string $block, string $template)

Description

Adds a block to the template changing a variable placeholder to a block placeholder. This means that a new block will be integrated into the template in place of a variable placeholder. The variable placeholder will be removed and the new block will behave in the same way as if it was inside the original template.

The block content must not start with <!-- BEGIN blockname --> and end with <!-- END blockname -->, if it does the error will be thrown.

Paramètres

chaîne de caractères $placeholder

name of the variable placeholder, the name must be unique within the template.

chaîne de caractères $block

name of the block to be added

chaîne de caractères $template

content of the block

Valeur retournée

return SIGMA_OK on success, error object on failure

Voir aussi

see HTML_Template_Sigma::addBlockfile()

Valeurs renvoyées

Tableau 42-1. Valeurs PEAR_Error possibles

Error codeError messageReasonSolution
SIGMA_BLOCK_EXISTSBlock '$block' already existsTried to add a block with a name that is already present in the templateChoose a different name for a new block
SIGMA_PLACEHOLDER_NOT_FOUNDVariable placeholder '$placeholder' not foundThere is no placeholder to replace by a new block in the templateCheck the spelling of the placeholder name
SIGMA_PLACEHOLDER_DUPLICATEPlaceholder '$placeholder' should be unique, found in multiple blocksA placeholder to be replaced by a new block should appear only in one placeCheck the spelling of the placeholder name, choose a different placeholder
SIGMA_BLOCK_DUPLICATEThe name of a block must be unique within a template. Block 'blockname' found twice.The added block contains a subblock that has the same name as the existing oneCheck 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

Cette fonction ne peut pas être appelée de façon statique.