<?php class Template { var $strTemplateDir = './layouty/'; var $strBeginTag = '{'; var $strEndTag = '}'; function Teplate( $template_dir ) { $this->strTemplateDir .= $template_dir; } function assign( $strVar, $strValue ) { $this->arrVars[] = $this->strBeginTag . $strVar . $this->strEndTag; $this->arrValues[] = $strValue; } function display( $strFile ) { $strFile = $strFile.'.tpl'; } } ?>
uzywam tego w ten sposob:
<?php $tpl = new template; $tpl->Teplate( $wybrany ); $tpl->assign( 'cos', $jakaszmienna); $tpl->assign( 'cos2', '<b>jakis kod html'); $tpl->display( 'index' ); ?>
Wszystko dziala ladnie pieknie, ale widzialem kiedys w skrypcie phpbb ze tak jak wyzej mam "assign" bylo w tablicy... chcialbym to samo osiagnac tylko niewiem jak
Dokladnie chodzi mi o taki efekt:
<?php $tpl = new template; $tpl->Teplate( $wybrany ); $tpl->assign( 'cos' = $jakaszmienna, 'cos2' = '<b>jakis kod html', // i tak dalej, po prostu wygodniej :) pomoze ktos ? ); $tpl->display( 'index' ); ?>