I'm sure it could be done, just with a bit of planning.
The notion of passing in sql results is not foreign - we do it
sometimes to our own 'templates', but our templates are generally
just HTML with a bit of PHP in there, whereas the initial PHP page
is PHP with a tiny bit of HTML. If there's a large result set that needs
parsing through, we'll normally do it in the PHP code, and write the results out to
a variable, substituted in the 'template'. You could instead have a 'template
system' or php itself loop through that in the 'template' itself - whichever makes
more sense to the end coders.
I'd THINK you could do what you wanted with an array
$sql = one row of SQL results, in a has.
Passing $sql to the template, you could then have
$sql["page_id"]
$sql["page_name"]
etc.
Pulling stuff from the database drivers into an associate array would do this -
is this what you're talking about?
andrew wrote:
> Sure,
>
> My understanding of templating engines
> 1.array or item is assigned to a variable
> 2.php placeholders in a html page match in name to above variable.
> 3.a parser separate from php subsitutes the variable values set in (1)
> into (2)
>
> I've seen plenty of examples where there is a file containing lists of
> variable to item assignment, and thase files are passed to a one of a few
> template pages for layout.
>
> There must be a way to pass the result set of an SQL query into the set of
> placeholders - the end result would be that you could call whole sites via
> simple queries. All you have to pass in would be the SQL parameter.
>
> i.e. Table named 'Pvalues'
>
> Pvalues Sample Row
> ---- ------
> page_id contactus.html
> page_name Contact Us
> page_title Contact US
> header_text Please send an email
> body_text [EMAIL PROTECTED]
> footer_text thanks!
>
> You can even generate a list of links dynamically for nav bar via:
>
> "select page_name, page_id from Pvalues", if you account for performance
> issues.
>
> If the usre clicks on the "contact us" link, it returns a page_id value of
> contactus.html. So then:
>
> "select * from Pvalues where page_id = "contactus.html"
>
> Then call a templating parser and pass it the values of the select statement
> and which template to use.
>
> Can this be done, or I am way off base on this?
>
> regards,
> andrew
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]