Page 1 of 1

template system

Posted: Thu Jun 02, 2005 9:27 pm
by jaymoore_299
I want to be get a template system going where it looks something like this:

html code

{php,
insert custom
data}

end of html

I want the contents within the bracket to be replaced by whatever I want, and everything else to be the same.
I want to be able to send specific variables within, such as:
{type NEWS
color BLUE
font COURIER
}
,which would return news article in color blue with courier font.
After creating the template, it would be saved as an html file with no php code in it.

What's the best way to do this?
Should I use <?php (variables) >? Is there any issue with using <?PHP ?>
multiple times throughout the page?

Posted: Fri Jun 03, 2005 1:14 am
by Syranide
... what you want is XML ...
searching the API or google will find you a quick example to get you up and running in 30min.

SimpleXML is really easy, if that is not available use the XML-parser and a function to make it easily read (can be found on php.net usercontributions).

Posted: Fri Jun 03, 2005 1:48 am
by ol4pr0
Get a closer look on what Mambo did, does.

Posted: Fri Jun 03, 2005 1:50 am
by patrikG
ol4pr0 wrote:Get a closer look on what Mambo did, does.
Mambo doesn't use templating.

Posted: Fri Jun 03, 2005 5:03 am
by Buddha443556
patrikG wrote:
ol4pr0 wrote:Get a closer look on what Mambo did, does.
Mambo doesn't use templating.
The do seem to use a Template View pattern and even Helpers although the use of scriptlets is probably obsene to some people.

Posted: Fri Jun 03, 2005 5:13 am
by patrikG
If there was a degree of consistency in their use of design patterns, plus a seperation of logic and view, it would be fantastic. Mambo's DB-class for example has some nice ideas & they seperate content and view, but not logic and view. And that's what I find most taxing: their constant mix of logic and view. Thus, while they are, by name, using "templates", they are not implementing the concept and are loosing the benefits by design.

Posted: Fri Jun 03, 2005 6:20 am
by Buddha443556
patrikG wrote:If there was a degree of consistency in their use of design patterns, plus a seperation of logic and view, it would be fantastic. Mambo's DB-class for example has some nice ideas & they seperate content and view, but not logic and view. And that's what I find most taxing: their constant mix of logic and view. Thus, while they are, by name, using "templates", they are not implementing the concept and are loosing the benefits by design.
Like I said some may find it obscene. However, I think the Mambo example maybe useful to jaymoore_299 because he does not seem to need anything more complex than good ol' PHP scriptlets.