[Phplib-users] template extensions
Brought to you by:
nhruby,
richardarcher
From: Evan H. <hu...@bi...> - 2003-01-14 18:49:16
|
Howdy, I'm the colleague that Mike mentioned. The remainder of this email is a more in-depth description of what Mike had mentioned. Dr Tarique Sani wrote: > On 13 Jan 2003, Mike Gifford wrote: > > <td><!-- main content --> > > {Article($ArticleId)} > one question > How will the $ArticleId be passed to the template? 'ArticleId' would be used as a key into the globals array. The germ of my idea doesn't rest on variable passing (although that could be a Good Thing, it isn't the basis of my idea). What I'm really interested in is backing variables with functions -- which would allow static pages to reference content that is generated dynamically. This would allow the creation of templates that require no intervention from PHP to render content. Consider the following situation: I'm building a site where I want all pages to follow a certain format, and contain a number of elements that are repeated between pages. However, different elements will appear on different pages (even though at coding time, I'm not sure what will appear where). Say that I want my dynamic elements to be: Poll - Dynamically generated poll RDF - RDF listing of the site's content Calendar - A calendar of events LoggedIn - A listing of who is logged in News - A listing of news items I know that these are necessary when I'm writing the code that will generate the site, but I'm not sure when or where they will be used (I'm not in control of final appearance/layout, someone else is). Using the current architecture I would be forced to define all of these elements before evaluating the templates, even if they aren't used in the page. In a function backed variable architecture, I would define a directory that would contain a listing of renderers that would produce output for a given variable names. So, for this example, I would have a directory that would contain a set of files (functions/Poll.php, functions/RDF.php, functions/Calendar.php, etc). When the parser in template.inc tried to link a variable reference that it doesn't know about, it would check this directory - if there is a file that matches the name of the variable, it would be evaluated and its output linked into that variable. The value of backing variables with functions should be apparent outside of this example: the one-file-per-variable constraint on content forces encapsulation of functionality into a single file that would have a well-defined interface. e |