smarty模版目录疑问

2013年4月5日 15:46:25

今天鼓捣yaf和smarty整合,用var_dump();打印出来了smarty对象,看到他其中存放模版目录的变量是用数组保存的,如下:

objSmarty
 1 object(Smarty)[15]
 2   public 'auto_literal' => boolean true
 3   public 'error_unassigned' => boolean false
 4   public 'template_dir' => 
 5     array
 6       0 => string 'F:/zzbserv/apache/htdocs/yaftwo/code/modules/test/templates' (length=59)
 7   public 'default_template_handler_func' => null
 8   public 'compile_dir' => string 'F:/zzbserv/apache/htdocs/yaftwo/code/templates_c' (length=48)
 9   public 'plugins_dir' => 
10     array
11       0 => string 'F:\zzbserv\apache\htdocs\yaftwo\code\library\Smarty\plugins\' (length=60)
12   public 'cache_dir' => string 'F:/zzbserv/apache/htdocs/yaftwo/code/cache' (length=42)

又去smarty官网上看了看有关模版的介绍,如下

setTemplateDir
 1 <?php
 2 // 设置单个模板目录
 3 $smarty->setTemplateDir('./cache');
 4 
 5 // 查看全部模板目录
 6 var_dump($smarty->getTemplateDir());
 7 
 8 // 批量设置模板目录
 9 $smarty->setTemplateDir(array(
10     'one' => './templates',
11     'two' => './templates_2',
12     'three' => './templates_3',
13 ));
14 
15 // 查看全部模板目录
16 var_dump($smarty->getTemplateDir());
17 
18 // 方法连用
19 $smarty->setTemplateDir('./templates')
20        ->setCompileDir('./templates_c')
21        ->setCacheDir('./cache');
22 
23 ?>

疑问:同时可以设置多个模版目录,设计者肯定有他们的考虑,但是他们考虑到了哪些方面,以至于要这样设计?

我想,不仅仅是为了将多个html模版分开存放在多个文件夹中,在一个文件夹下找不到的话再去另一个文件夹下去找吧?

要是这样的话,那不同文件夹下的html模版文件名字肯定不能重复了

是否另有深意?

原文地址:https://www.cnblogs.com/iLoveMyD/p/3000904.html