Topic awaiting preservation: Templating and Parsing PHP in the Template |
|
---|---|
Author | Thread |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 06-03-2005 19:50
So, having long reached the limits of what I could accomplish with SSI and being so proud of myself for writing a working PHP script, I decided to move into PHP templating. After some research, I decided Smarty was too robust for these smaller sites I'm working on (though I may use it for my personal sites in the future) and instead settled on a simple script I came across. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 06-03-2005 21:30
Woah! code: / - templates -- head.php -- foot.php -- menu.php - index.php
code: <?php include($_SERVER['DOCUMENT_ROOT'] . "/templates/head.php"); ?> <!-- The HTML or PHP Content Goes in Here --> <?php include($_SERVER['DOCUMENT_ROOT'] . "/templates/foot.php"); ?>
|
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 06-04-2005 03:27
Well, I've done that with PHP includes, but like you said, that's pretty much like what I was doing with SSI, with PHP functionality. But then I end up with includes within includes and often have to track down where the different bits are to change something. code: <?php require_once($_SERVER['DOCUMENT_ROOT']."/templates/template.class"); $page = new Page("template.html"); $page->replace_tags(array( "title" => "The title for this specific page.", "feature-item" => "This is the feature item.", "body" => "Body stuff here.", )); $page->output(); ?>
code: <html> <head> <title>{title}</title> </head> <body> <Layout> <Layout> <Layout> {feature-item} <Layout> <Layout> <Layout> {body} <Layout> <Layout> <Layout> </body> </html>
|
Maniac (V) Inmate From: Sthlm, Sweden |
posted 06-05-2005 14:10
quote: and that's pretty much what smarty does. |
Paranoid (IV) Inmate From: Minneapolis |
posted 06-06-2005 16:15
Wes, you should really check out my earlier post about Templation to be released under the GPL in September. Even though the system is written in PHP, it doesn't conflict with your code, because it creates the final page using readfile() instead of include(), so your page is built in a sandbox and only executed after Templation has completed it's processing. |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 06-07-2005 02:55
DmS, I think I'm going to end up doing what you've suggested and define tags that trigger functions in the script, at least for this site. It's pretty small, so there shouldn't be that much to do. |
Paranoid (IV) Inmate From: Minneapolis |
posted 06-07-2005 17:08
The code is pretty solid, so I'm looking for beta testers mostly to make the setup easier and suggest what kind of tools I should develop this summer before the public release. Once it's installed properly (which of course I can help with) you never even really see PHP code, which is one of the strong points. I'm currently simplifying the install process so you should be able to try it out mostly by dropping a few files in place. When I'm done I'll shoot you an email... |