Ben şablonları toplar ve tüm şablonları bağladıktan sonra nihai çıkış görüntüleyen bir sınıf var.
class Template{
$private $output = '';
public function Load_Template($template, $data = null){
ob_start();
include($template);
$this->output .= ob_get_clean();
}
public function Display($add_footer = true){
echo $this->output;
}
}
Şimdi, Şu anda benim şablonları bu gibi bir şey.
<h1><?php echo $data['name']; ?></h1>
veya döngüler içeren daha karmaşık olanlar daha benziyorsun
<ul>
<li>
<?php foreach($data as $user){ ?>
<h1><?php echo $user['name']; ?></h1>
<?php } ?>
</li>
</ul>
Actually theres way more data than that in them, but im sure you guys get the point. Now, I have heard people say thats it better to have templates like this
<h1>{name}</h1>
veya
<ul>
<li>
<h1>{name}</h1>
</li>
</ul>
and then use a str_replace function... Now, if im using a foreach loop, how would I accomplish something like this... should i alter my class, and if so can i get some ideas as to how... And do you guys suggest using templates with