Re: [Phplib-users] template extensions
Brought to you by:
nhruby,
richardarcher
|
From: Andrew C. <An...@Ev...> - 2003-01-14 06:41:05
|
At 09:42 PM 1/13/2003 -0500, Mike Gifford wrote:
>Evan's thought was that it would be really, really nice there were hooks
>for calling functions right in the templates, allowing our pages to look
>something like:
>All of those functions (stuff in curlies with '()'s after the name)
>would resolve to a php function that would be called (or maybe a file
>that would be evaluated as php, or something =). That would really clean
>up the content files, and provide really, really nice modularization.
Maybe I'm not understanding something. That just seems backwards to
me. Normally, the PHP file is being evaluated and pulls formatting
information from the template. So, now, the template would be evaluated
and pull code from another file? Why?
Instead of putting those functions in the template, couldn't you just put
template variables in the template and have the PHP code filling in the
template perform the functions for those variables?
Or, if there is some reason I am missing to want to do this, why use
templates at all? Why not just use straight PHP and use <?php include
your_function.php; ?> or <?php your_function(n); ?> in place of your
curly-bracketed functions?
At 06:59 PM 1/13/2003 -0800, Aric Caley wrote:
>It seems to go against the general idea of templates: to separate code from
>presentation.
It seems that way to me, too.
>It would also be nice for the templates to be able to use this to tell the
>code what to do in certain cases. For instance, what if the template has a
>4 by n grid. But the designer wants it changed to, say 6 wide. Currently
>you'd probably have a nested set of blocks (one for horizontal, one for
>vertical) and the code would determine how many wide to go, so the
>programmer would have to go in and change that. With this you could just
>have something like this:
>
>{setmatrix(4)}
><!-- BEGIN matrix -->
><img src="block.gif">
><!-- END matrix -->
>
>And the code would know what to do.
... or, you could code that as a variable in a configuration file or the
header section of your PHP file that fills in the template. Then, the PHP
file could determine what to do with that information. Strangely enough,
I've done exactly that with some of the stuff I have developed.
For example, an image gallery thumbnail page has a configuration file that
has variables like thumbs_num_rows and thumbs_num_columns. The designer
can choose the numbers after the equal signs without even as much brain
power as required to understand the {setmatrix(4)} syntax. You can even
put a more detailed comment right before the settings for the unusually
obtuse designer. The PHP code then iterates appropriately when filling in
the template. It works great.
Andrew Crawford
An...@Ev...
|