rb:insertblock
Insert output text from a named XML block BodyIncludes any valid XML/HTML markup Attributes
Attribute |
Required |
Description | name | required | The name of the XML block to insert. Blocks are identified using the
rb:id attribute |
RemarksThis tag has been added with version 0.9.32 of the Presentation Engine and is not available in previous
versions. It is possibleto write a macrotag that simulates
this functionality in earlier versions. This tag allows the author to insert the output of a block of XML into the output of a page. This
is most often used in conjunction with the <rb:block ...> tag
which identifies a block. The name attribute idenfies the block we want to include in the output
stream. Blocks are identified by marking them with an rb:id
attribute. Use of this tag can help you structure your presentation pages in a way that makes their behaviour clearer,
which in turn of course aids maintainance. When the <rb:insertblock...> tag is encountered when generating a page, the Presentation Engine will
search the XML tree for the named block. If the block is not found then no output is generated. If the named block is found then the XML subtree is executed and the textual output from that tree
is used to replace the <rb:insertblock...> in the output stream. Note that the XML tree itself is not copied. That is the XML DOM itself is not modified by this tag. ExampleThis is a very simple example of how to structure a page so that it is easy to maintain. Note that
this technique is especially powerful when one considers that the blocks can be included in a header file
allowing the same header/footers etc to be applied to all pages very easily.
<rb:block rb:id="topbanner">
<!-- Logo, links etc that appear at the top of the page -->
</rb:block>
<rb:block rb:id="leftmenu">
<!-- Menu that appears at the left -->
</rb:block>
<rb:block rb:id="footer">
<!-- Footer with copyright notice etc -->
</rb:block>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="2">
<rb:insertblock name="topbanner"/>
</td>
</tr>
<tr>
<td width="150">
<rb:insertblock name="leftmenu"/>
<td>
<td>
<h1>Page body</h1>
<p>This is the bit that changes</p>
</td>
</tr>
<tr>
<td colspan="2">
<rb:insertblock name="footer"/>
</td>
</tr>
</table>
You can combine the an rb:insertblock tag with the rb:test attribute to make blocks
conditional. The example above could be extended for example to include a login-block, which is only included if the
site visitor is currently not logged into the site. |