Once you filled all variables in a block, you want to “save” them to be able to re-use the block another time. Method parse() is useful here. First parameter is the variable/handle in which the block content shall be stored, second is the handle name of the block. The optional third parameter tells if you want to append the block content to the handle value or not – it defaults to false, but you probably want to do that.

Parsing a block
 
<?php 
foreach ($authors as $name => $email) {
    $this->setVar('AUTHOR_NAME', $name);
    $this->setVar('AUTHOR_EMAIL', $email);
    $this->parse('authorline_block', 'authorline', true);
}
?>

In this example, handle authorline_block is filled with the contents of block authorline. If the third parameter would be false instead of true, only the last line would be in it at the end.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>