Template Sigma Help
| From: | Ian Warner | Date: | Sat, 30 Sep 2006 14:53:22 +0000 |
| Subject: | Template Sigma Help | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-25317@lists.php.net to get a copy of this message | ||
Hi
Ok so took Betrands advice (thanks) and started using the Sigma template:
I created the following as a test:
wrapper.tpl
<!-- BEGIN tr -->
<div id="wrapper">12345</div>
<!-- END tr -->
<p class="skipLink">
<a href="#main" accesskey="2">Skip to main content</a>
</p>
</div>
// Load template file.
$tpl->loadTemplatefile('wrapper.tpl');
$tpl->setCurrentBlock('tr');
$tpl->parse('tr');
$page->addBodyContent($tpl->get());
Now from what I gather this should just print out <div id="wrapper">12345</div> - but on the contrary it is printing out
<p class="skipLink">
<a href="#main" accesskey="2">Skip to main content</a>
</p>
</div>
which is the opposite.
I have tried a lot of variations with no luck. adding in $tpl->parseCurrentBlock(); and $tpl->parseCurrentBlock('tr'); and just get('tr'); etc still always print out the same or nothing.
By the way I am using HTMLPage2 also hence the addbody content, however unfortunately it does not render the output and format from Sigma, i tried without rendering through this and same also.
Now I got it working nicely with :
$tpl->loadTemplatefile('1_column.tpl');
// Create an array for table data.
$data = array (
'th' => array('First Name', 'Surname'),
1 => array('Stig', 'Bakkecn'),
2 => array('Martin', 'Jansen'),
3 => array('Alexander', 'Merz')
);
// Print out a table formated for Tamplate Sigma
foreach($data as $k => $v) {
if ($k != 'th') {
$k = 'td';
}
$tpl->setCurrentBlock($k);
foreach($v as $$k) {
$tpl->setVariable('DATA', $$k);
$tpl->parseCurrentBlock();
}
$tpl->parse('tr');
}
// Add content and display.
$page->addBodyContent($tpl->get());
and tpl
<table class="tbl">
<!-- BEGIN tr --><tr>
<!-- BEGIN th --> <th class="title">{DATA}</th>
<!-- END th --><!-- BEGIN td --><td>{DATA}</td>
<!-- END td --></tr>
<!-- END tr --></table>
Cheers
Ian