Help requested - using HTML_Template_Sigma
| From: | Stephen Torri | Date: | Wed, 25 Jun 2003 02:56:53 +0000 |
| Subject: | Help requested - using HTML_Template_Sigma | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-6218@lists.php.net to get a copy of this message | ||
I am a bit stuck on the basics of using HTML_Template_Sigma. The problem
I am having is actually parsing the template and replacing the values.
Here is my index page's template:
------------------------------
index.tpl.html
------------------------------
<html>
<head>
<!-- BEGIN meta -->
{meta_info}
<!-- END meta -->
<!-- BEGIN css -->
{css}
<!-- END css -->
</head>
<!-- #TODO {menu_css} -->
<!-- #TODO {menu_js} -->
<body>
<!-- Note: Main table -->
<table width="100%" border="0" cellpadding="0"
cellspacing="0">
{title_bar}
{menu_html}
<!-- #TODO {google} -->
{content}
</table>
<!-- end Main table -->
</body>
</html>
<!-- BEGIN signature -->
{signature}
<!-- END signature -->
I am trying to replace the 'meta' block. So I have the template created
in the index.php3 file:
-------------------------------
index.php3
-------------------------------
<?php
require_once "DB.php";
require_once "HTML/Template/Sigma.php";
include_once "includes/secrets.inc.php3";
include_once 'includes/meta.inc.php3';
include_once 'includes/signature.inc.php3';
include_once 'includes/menu.inc.php3';
// Data Source Name: This is the universal connection string
$dsn = "mysql://$user:$pass@$host/$db_name";
// Database connect
$db = DB::connect($dsn);
// With DB::isError you can differentiate between an error or
// a valid connection.
if(DB::isError($db)) {
die ($db->getMessage());
}
// Load template
$tpl = new HTML_Template_Sigma("./templates");
$tpl->loadTemplatefile("index.tpl.html");
// {meta}
// Set meta info
generate_meta($tpl);
$tpl->show();
// You can disconnect from the database with:
$db->disconnect();
?>
The 'generate_meta' functions is:
------------------------------
meta.inc.php3
------------------------------
<?php
function generate_meta ($tpl) {
$tpl->setCurrentBlock('meta');
$text = "<meta name=\"description\" content=\"Personal web page of
Stephen A. Torri\">";
$tpl->setVariable('meta_info',"Foo");
$tpl->parseCurrentBlock('meta');
}
?>
Yet the resulting HTML code does not have the 'meta' tag line in it. I
need assistance or a tutorial/howto page. What is wrong with this code?
Stephen
--
Stephen Torri <storri@sbcglobal.net>
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc