napisałem własną klasę templatów. Chciałbym teraz obsłużyć w niej instrukcje warunkowe, na początek zwykły if.
Proszę o sugestie
*/ class class_templates{ /** * core references */ private $uniclass; private $input; private $output; function __construct( $uniclass) { $this -> uniclass = $uniclass; $this -> input = class_input::getInstance(); $this -> output = class_output::getInstance(); } /** * select template name * * @return: mixed */ public function getTemplateName() { // download data $settings = $this -> uniclass -> db -> query("SELECT * FROM settings"); // return data return $this -> templateData($row['template'], 'name'); } /** * download data from template id * */ private function templateData( $id, $field) { // get data from db $data = $this -> uniclass -> db -> query("SELECT * FROM templates WHERE id='". $id ."'"); return $row[$field]; } /** * load template * */ public function loadTemplate( $file, $array) { //add sufix to name $templateFile = $file . '.html'; try { //parse data foreach($array as $text => $value) { //2D arrays //parse 2D data foreach($value as $twoDtext => $twoDvalue) { //change texts on values (2D) $template = str_ireplace( '{$'. $text .':'. $twoDtext .'}', $twoDvalue, $template); } } else { //change texts on values $template = str_ireplace( '{$'. $text .'}', $value, $template); } } } else { throw new exception_fatal_error( "Data to the template must be in an array.", 0); } }catch ( exception_fatal_error $exception){ //trow error } //run template return $template; } } ?>