Thankyou everyone who responded to my original message. All of your ideas
have showed me the various ways of doing it, however I believe that the idea
from Jons message is best suited to my needs. I realise the logic behind it,
its put together some knowledge I have already so I think I'll use it for
the time being.
Thankyou for taking the time to respond to my message.
Regards,
Alex
On 14/6/06 19:48, "Jon Anderson" <[EMAIL PROTECTED]> wrote:
> This is my opinion on the matter...
>
> From experience, I would say that mixing PHP and HTML together in a
> complicated page can often get very ugly. I prefer to separate out
> presentation and code into separate layers as much as possible.
>
> I have most often used template systems such as Smarty (smarty.php.net)
> for that. I use Smarty for work - I find it quite nice. It allows you to
> separate your code from your presentation very effectively. It's easy to
> use, and provides things like caching for performance.
>
> However, I came to the realization recently that PHP itself is
> essentially a very feature rich template system (nevermind the fact that
> it's a well defined language. ;-)
>
> By splitting up my most recent project into includes, templates, and
> pages, I get a solution to the problem in pure PHP. In the end, code
> looks like code, and HTML looks (almost) like HTML and both are
> readable. (Same result as what Smarty gives you, without needing Smarty.)
>
> Most pages look something like:
>
> <?php
> include('include/data_functions.php');
> if ($condition) {
> $title = 'Here is Some Data!';
> $data = getSomeData($var1,$var2);
> } else {
> $title = 'Here is the Other Data!';
> $data = getOtherData($var1,$var2);
> }
> include('template/page.php');
> ?>
>
> And most templates look something like:
>
> <?php include('template/head.php'); ?>
> <h1><?= $title ?></h1>
> ...
> <table>
> <?php foreach ($data as $item) { ?>
> <tr>
> <td><?= $item['part1'] ?></td>
> <td><?= $item['part2'] ?></td>
> </tr>
> <?php } /* END foreach ($data as $item) */ ?>
> </table>
> ...
> <p>Thanks for your interest in my data!</p>
> <?php include('template/foot.php'); ?>
>
> jon
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php