|
Posted by Jerry Stuckle on 09/28/54 12:01
bizt wrote:
> Hi,
>
> When I create a website in php I may have a page called products.php.
> This script will contain any code required to produce a list of
> products and build them into an array of objects perhaps. At the
> bottom of the script I would have the following:
>
> include_once('template.products.php');
>
> This page will be the HTML with embedded PHP to output the list of
> products:
>
> <table ...>
> <?php foreach($arProducts as $product): ?>
> <tr>...</tr>
> <?php endforeach; ?>
> </table>
>
> This appears very similar to something like Smarty exept I prefer to
> have the use of objects and their methods when using the template.
> Also I read an article on it that made a point that Smarty doesnt
> really do much more than PHP as a template engine (as my above example
> demonstrates).
>
Not just Smarty - very common, even if you're not using templates. I
regularly include things like this - especially when they're being used
on multiple pages.
> Now XSLT is something I dont really have a lot of practical experience
> in. I know how to create an XSL file but how is it best used in PHP.
> Should the XSL be used to output a whole HTML page <html>...</html> or
> just simple a table or something. I would have to convert my data to
> XML to perform the transformation and this just seems like an extra
> process required from my own technique. XSLT has been around for a bit
> now and it would seem with the added support for it in PHP5 it is very
> useful
>
What do you need XSLT for, anyway? Do you have a specific need?
As for what to output - it all depends on the circumstances. If the
code is always going to be a full page, and never have anything else on
that page, go ahead and put the <html>...</html> code in there. But
that limits your reuse.
Remember - the biggest advantage of include files is reusability.
Include too much and you limit that reusability.
> Anyway, the point of this post is just to get peoples opinions on
> outputting the front end of a page. My technique of using PHP for
> templating works well for me but I may be wrong in other
> circumstanses. Any guidance on this area would be much appreciated
>
> Cheers
>
> Burnsy
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|