Trying to create a site-template system.. and..
| From: | Ryan Christensen | Date: | Sat, 27 Oct 2001 01:03:27 +0000 |
| Subject: | Trying to create a site-template system.. and.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-72540@lists.php.net to get a copy of this message | ||
First.. here's the synopsis of what I'm trying to do:
I'm working on a site where everything is based off a really simple template
system I'm using, see the chunk of my index page that deals with the plates
for example:
---------------------------------------------
$tmpl_file = fopen ("./template.htm", "r");
$tmpl = fread($tmpl_file,16000);
$tmpl = str_replace("{title}", "$title", $tmpl);
$tmpl = str_replace("{header}", "$header", $tmpl);
$tmpl = str_replace("{header_url}", "$header_url", $tmpl);
$tmpl = str_replace("{header_home}", "$header_home", $tmpl);
$tmpl = str_replace("{header_cat}", "$header_cat", $tmpl);
$tmpl = str_replace("{header_caturl}", "$header_caturl", $tmpl);
$tmpl = str_replace("{header_title}", "$header_title", $tmpl);
$tmpl = str_replace("{pretext}", "$pretext", $tmpl);
$tmpl = str_replace("{content}", "$content", $tmpl);
$tmpl = str_replace("{content_source}", $page_source, $tmpl);
eval("echo \$tmpl;");
---------------------------------------------
The template file looks like "blah.. blah.. {title}.." the code above then
takes the {blah} tags, and turns them into variables, which are defined in
the actual content pages (which are included (via an include(); function..)
The content files appear as:
---------------------------------------------
$title = "testing";
$content = "etc";
---------------------------------------------
And so on..
My problem is.. that when I do something like
---------------------------------------------
$content = show_source("/path/to/file");
// or
$content = "Blah.. blah.. ".include("/some/file").".. some more
blah..";
---------------------------------------------
It includes the files (or executes the code that is assigned to the
variable), however it all appears OUTSIDE the template. To see what I'm
saying, see http://olypen.com/ryan/go/main/news or
http://olypen.com/ryan/go/source/source_index
.. that will give you a better
idea as to what I'm saying.
Anyone have any thoughts/explanations as to why this is happening? I can
provide more source.. or info if needed.
Thanks in advance!
-Ryan