Templating help

From: Date: Wed, 10 Jan 2001 08:09:35 +0000
Subject: Templating help
Groups: php.general 
Request: Send a blank email to php-general+get-33630@lists.php.net to get a copy of this message
ok, im working on a simple and fast templating system for the website im recreating at the moment. im trying to make it so as the template file can be opened into a variable before it is passed to the parsing section so as i dont have to open the file 100 times etc. im not using fasttemplates because it is to complicated for my liking and nothing out there seems to be much good. can someone look over this code and tell me why its screwing up? template.php <?php $template_root = "blah blah"; function template_open ($template_file) { global $template_root; $template_file = "".$template_root."".$template_file.""; return implode("",(@file($template_file))); } function template_parse ($template_file, $template_replace, $template_data, $template_type=0) { global $template_root; /* ****************************************************** * $template_type decides weather $template_file is a * * local file or is already data (ie. already sucked * * the template into a variable. * ****************************************************** */ if ( $template_type == '0' ) $template_contents = implode("",(@file($template_root.$template_file))); if ( is_array ( $template_data ) && is_array ( $template_replace ) ) { for ( $i=0; $i < count ( $template_replace ); $i++ ) { $template_contents = str_replace("{".$template_replace[$i]."}", $template_data[$i], $template_contents); } } else { } return $template_contents; } $tpl_replace = array ("NAME", "DATE" ); $tpl_data = array ("test_name", "test_date"); $dl_temp = template_open("download/row.tpl"); $blah = template_parse($dl_temp, $tpl_replace, $tpl_data, 1); echo $blah; ?> row.tpl {NAME} {DATE} {STYLE} {REVIEW} {LINK}

« previous php.general (#33630) next »