If you're wondering how meta tags and other such elements get inserted into the head of your template output without your doing, it's through an XT feature called "tag binding".
Tag binding allows you to call a PHP function to "bind" or attach a piece of output (ie. additional tags or content) to tags within a template, without having to insert XT tags to specify that they should go there. You can even bind values to attributes of tags that don't necessarily have that attribute in the template itself. For example, the page_onload() function binds a value to the onload attribute of your HTML body tag, regardless of whether your body tag has an onload attribute specified in your template or not.
Tag binding is used primarily in the page_*() functions (ie. page_add_script(), page_add_meta(), page_add_link(), and page_add_style(), as well as page_onload(), page_onfocus(), etc.) to dynamically add links, meta tags, stylesheets, and Javascript to templates as needed (ie. a <link rel="alternate" /> for RSS feeds).
The relevant functions that do this magic are template_bind() and template_bind_attr() in the saf.XML.XT package. You can use them like this:
<?php
template_bind (
'/html/head',
'<link rel="alternate"... />'
);
template_bind_attr (
'/html/body',
'onload',
'alert ("hello world!")'
);
?>
Revision from August 1, 2007 1:15 PM by admin
Forward in time (1 more) | See current | See changes | Linked from: Templates