Currently I have a simple class which basically replaces all tags (eg, {Message}, {Title}) in html templates with indicated values. Well, that's very simple, but what about more sophisticated dynamic content? Currently for dynamic content, I also have {} tags. For example, for a list of db records, I use {List} tag, which is replaced with HTML which is produced by a PHP file which looks like this:
Code: Select all
<div id="record_container" class="med_bg">
<form method="post" action="../process/news.php?do=delete">
<table>
<tr>
<th>Headline</th>
<th class="padding_side">Posted</th>
<th> </th>
</tr>
<?php
while ($row = $rs->NextRow())
{
echo '<tr><td><a href="view_news.php?item=' . $row['id'] . '">' . $row['headline'] . '</a></td>';
echo '<td class="padding_side">' . $row['date'] . '</td>';
echo '<td><input type="checkbox" name="item_array[]" value="' . $row['id'] . '" /></td></tr>';
}
?>
<tr>
<td colspan="3"><input type="submit" value="Delete Selected" /></td>
</tr>
</table>
</form>
</div>I am not happy with this approach, because the HTML formatting IS inside a PHP file, when most of other HTML is in simple .htm files with {} tags. So, in my case, if I wanted to change HTML design of the site, I would have no prob with static .htm templates, but I WOULD need to go and dig the dynamic content generating .php files to change HMTL there as well. Not that good for myself, for others even more so.
So my question is, how do you implement dynamic content in templating class? I would really like to make my own templating class, for better understanding of things, just I'm having some difficulties right now.
Would like to hear your input on the same.