Ok. Here's what I have so far, and how it works:
PHP Code:
<?php
include("ultratemplate.php"); // I'm going to change it to "odan.php"
include("datasource.php"); // This is the data abstraction class
//the code
$ds = new DataSource();
$arrResult = $ds->read("select user,email from users;",DS_TYPE_MYSQL,array("user"=>"***","password"=>"***","database"=>"mydb"));
// When reading from a database, the data abstraction class returns the whole result as an array (indexed or hash; hash is default)
//
Basically this function loads the template and parses the tags within it.
page_start("mylayout.php"); // Using a .php file is more secure than a .tpl file, unless you have access to your server
$rpt1->datasource = &$arrResult;
page_bind(); // Run all the bind functions for the tags.
page_display(); // Display the final output.
That's the basic code to use the builtin repeater. Here's the template:
Code:
<html>
<body>
<repeater:rpt1>
<header_template>
<table border="0">
</header_template>
<item_template>
<tr>
<td rowspan="2"><img src="/images/users/#user#.jpg" /></td>
<td>User: #user#</td>
</tr>
<tr>
<td>Email: #email#</td>
</tr>
</item_template>
<alternate_item_template>
<tr>
<td rowspan="2"><img src="/images/users/#user#.jpg" /></td>
<td>User: #user#</td>
</tr>
<tr>
<td>Email: #email#</td>
</tr>
</alternate_item_template>
<footer_template>
</table>
</footer_template>
</repeater:rpt1>
</body>
</html>
That's it. The "#...#" delimiters tell the repeater where to insert the data for each column. Also, It may take a little more html than some of the other solutions, but I think it looks better.
See my previous post for the location of a running demo. I haven't benchmarked it yet. I hope it's not awfully slow, It shouldn't be though.
Bookmarks