Table of Contents

Core Wrap Tag

CORE:WRAP

Wrap a named tag with the contents of a file

Syntax

<core:wrap file="filename" placeholder="id name">

Description

The core:wrap tag is a CompilerDirectiveTag and has no corresponding Component.

The contents of the current file are placed inside the contents of the file specified in the file attribute, replacing the PlaceHolderComponent refered to by name from the httpplaceholder tag.

Note to beginners: You don’t need a closing tag for this.

Examples

A quick example to make this less abstract:

Let’s suppose you have a page controller where you want to load some variable content, like a specific news item:

...
$Page =& new Template('/' . $newsitem . '.tpl.htm');
$Page->display();

Now, one of your actual news items, e.g. a file called “04101980hilly.tpl.htm”, might contain this:

<core:WRAP file="/main.tpl.html" placeholder="Content"/>
04/10/1980: Buddy Hilly goes east
This is your news item text.

See the reference to the main.tpl.htm at the top? The main template might contain a header and footer, and is “wrapped” around your content. You have to put a <core:PLACEHOLDER> tag in the main template to tell the compiler where to put the content. The ID of this tag must match the “placeholder” attribute you defined in your news item template.

main.tpl.htm might contain this:

...
<core:include file="header.tpl.htm">
 
<core:placeholder id="Content">
 
<core:include file="footer.tpl.htm">
...

That’s it. You’ll find another example in the tag examples section.