PHP: <? $template = file_get_contents ('template/win_privat.tpl'); $template = str_replace ('{time}', $nextrow['time'], $template); $template = str_replace ('{who}', $nextrow['who'], $template); $template = str_replace ('{privat}', $nextrow['privat'], $template); $template = str_replace ('{what}', $nextrow['what'], $template); echo $template;?> Есть вот такой код... HTML: <!-- win_privat.tpl --> <link rel=stylesheet href="template/style.css" type="text/css"> <body class="font_txt"> <a target"messages" href="#" onClick="parent.frames['messages'].document.getElementById('message').value = parent.frames['messages'].document.getElementById('message').value + ' см. ' + this.innerHTML + ' ';">[{time}]</a> > <a target"messages" href="#" onClick="parent.frames['messages'].document.getElementById('privat').value = this.innerHTML; return false;">{who}</a> -> <a target"messages" href="#" onClick="parent.frames['messages'].document.getElementById('privat').value = this.innerHTML; return false;">{privat}</a> :{what}<br> </body> Вопрос: как в win_privat.tpl поместить еще одну переменную {error}, но так, чтобы она выводилась если выполняется некое условие в php файле, lg еще и что бы все остальное НЕ выводилось )) Всё должно быть в одном файле, что бы можно было редактировать
PHP: <? $template = file_get_contents ('template/win_privat.tpl'); if (empty($error)) { $template = str_replace (array('[if_no_error]','[/if_no_error]','{error}'), '', $template); $template = str_replace ('{time}', $nextrow['time'], $template); $template = str_replace ('{who}', $nextrow['who'], $template); $template = str_replace ('{privat}', $nextrow['privat'], $template); $template = str_replace ('{what}', $nextrow['what'], $template); }else { $template = preg_replace ("#\[if_no_error\](.+?)\[\/if_no_error\]#is", "", $template); $template = str_replace ('{error}', $error, $template); } echo $template; ?> HTML: <!-- win_privat.tpl --> {error} [if_no_error] <link rel=stylesheet href="template/style.css" type="text/css"> <body class="font_txt"> <a target"messages" href="#" onClick="parent.frames['messages'].document.getElementById('message').value = parent.frames['messages'].document.getElementById('message').value + ' см. ' + this.innerHTML + ' ';">[{time}]</a> > <a target"messages" href="#" onClick="parent.frames['messages'].document.getElementById('privat').value = this.innerHTML; return false;">{who}</a> -> <a target"messages" href="#" onClick="parent.frames['messages'].document.getElementById('privat').value = this.innerHTML; return false;">{privat}</a> :{what}<br> </body> [/if_no_error] или юзать Смарти =))