Anyone feeling like they want to give me a 101 on general template handling in
PHP?
My history
I used to be a Roxen guy, where you could define your own HTML-tags, so that
"<foo />" could be set by "<define tag='foo'>Hello World</define>" so every
time you use the tag <foo /> it would be parse and replaced with "Hello World".
Naturally, within a <define>, any kind of roxen code can be used.
Today
I am using "php_value auto_prepend_fi le" and "php_value auto_append_fil e" to
insert a header and foot script to create the layout of a page, and function()
in required files to make small scriptlets such as headline() and stuff like
that.
The problem
With PHP, I can't make containers. Not real ones anyway. In Roxen, I could have
done this:
<define container="head line">
<span class="headline ">
<contents />
</span>
</define>
So <headline>Hello !</headline>
Would become <span class="headline ">Hello!</span>
You get the idea.
Now, with PHP, the above would be:
function headline($headl ine){
print "<span class='headline '>$headline</span>";
}
But the obvious problem is when you want to use this function for more than
just a small string - you might want a big block of HTML and PHP code to be
contained inside a HTML table with a border - for example. In Roxen this would
be done by:
<square>
Big old chunk of text, html, mysql, rxml or whatever.
</square>
And the end result would be that big chunk of text surrounded with the code of
a table. This is useful for lots of things, bbut generally for framing things
in different ways - mainly for news-boxes on pages
Currently, Im am doing this in php this way:
<?=square("star t") ?>
Big old chunk of text, html, mysql, rxml or whatever.
<?=square("end" ) ?>
But that's just ugly code and cumbersome.
Now to the point (finally!) - How does templating workm, and could it be used
to accomplish what I am trying to do here? I am aware of 'Smarty' and I have
downloaded it and played with it, but it was just a difficult concept to grasp
for me (yeah,. so call me stupid) and it did caching and had compiled scripts
and whatever. Isn't there a smpler solution?
Nayway, I'm grateful for any help in this area. :)
--
Sandman[.net]
PHP?
My history
I used to be a Roxen guy, where you could define your own HTML-tags, so that
"<foo />" could be set by "<define tag='foo'>Hello World</define>" so every
time you use the tag <foo /> it would be parse and replaced with "Hello World".
Naturally, within a <define>, any kind of roxen code can be used.
Today
I am using "php_value auto_prepend_fi le" and "php_value auto_append_fil e" to
insert a header and foot script to create the layout of a page, and function()
in required files to make small scriptlets such as headline() and stuff like
that.
The problem
With PHP, I can't make containers. Not real ones anyway. In Roxen, I could have
done this:
<define container="head line">
<span class="headline ">
<contents />
</span>
</define>
So <headline>Hello !</headline>
Would become <span class="headline ">Hello!</span>
You get the idea.
Now, with PHP, the above would be:
function headline($headl ine){
print "<span class='headline '>$headline</span>";
}
But the obvious problem is when you want to use this function for more than
just a small string - you might want a big block of HTML and PHP code to be
contained inside a HTML table with a border - for example. In Roxen this would
be done by:
<square>
Big old chunk of text, html, mysql, rxml or whatever.
</square>
And the end result would be that big chunk of text surrounded with the code of
a table. This is useful for lots of things, bbut generally for framing things
in different ways - mainly for news-boxes on pages
Currently, Im am doing this in php this way:
<?=square("star t") ?>
Big old chunk of text, html, mysql, rxml or whatever.
<?=square("end" ) ?>
But that's just ugly code and cumbersome.
Now to the point (finally!) - How does templating workm, and could it be used
to accomplish what I am trying to do here? I am aware of 'Smarty' and I have
downloaded it and played with it, but it was just a difficult concept to grasp
for me (yeah,. so call me stupid) and it did caching and had compiled scripts
and whatever. Isn't there a smpler solution?
Nayway, I'm grateful for any help in this area. :)
--
Sandman[.net]
Comment