Besides the existence开发者_如何转开发 of Smarty.class.php (which is also arguable), how do we know that a php project is using smarty template framework just by looking at its file structure?
Usually well-structured projects will have a template and template_c folder - although the names can be configured/changed. Additionally look for .tpl files in these folders.
The best approach I can see is to grep for common smarty functions like fetch/assign/display or common smarty tags like {foreach}, {assign}, {if}, etc.
You might need to poke around to find the templates and templates_c - in one of my projects they're not even in htdocs - the smarty folder is at the same level as htdocs. And we named our Smarty class based on the project, so even looking for "new Smarty()" wouldn't work.
I think the first answer that recommend looking for common smarty functions might be your best bet.
I think you can figure it out via checking the basic view class.E.g
class View
{
protected $tpl;
protected $tplfilename;
public function __construct()
{
$this->tpl = new Smarty();
$this->tpl->template_dir = dirname(__FILE__)."/templates";
$this->tpl->compile_dir = dirname(__FILE__)."/templates_c";
$this->tpl->config_dir = dirname(__FILE__)."/configs";
$this->tpl->cache_dir = dirname(__FILE__)."/cache";
$this->tpl->left_delimiter = "{|";
$this->tpl->right_delimiter = "|}";
$this->tplfilename = "default.tpl";
}
public function show()
{
$this->tpl->display($this->tplfilename);
}
}
This should probably be a typical smarty style.
精彩评论