smarty模版目录疑问

简介: 2013年4月5日 15:46:25 今天鼓捣yaf和smarty整合,用var_dump();打印出来了smarty对象,看到他其中存放模版目录的变量是用数组保存的,如下: objSmarty 1 object(Smarty)[15] 2 public 'auto_liter...

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模版文件名字肯定不能重复了

是否另有深意?

目录
相关文章
|
4月前
|
C++
CLion创建C/C++文件时添加模板代码
CLion创建C/C++文件时添加模板代码
CLion创建C/C++文件时添加模板代码
|
4月前
|
安全 编译器 C++
C++之模版初阶(简单使用模版)
C++之模版初阶(简单使用模版)
|
4月前
markdown增加目录索引,实现点击目录跳转到对应的内容目录标题
markdown增加目录索引,实现点击目录跳转到对应的内容目录标题
80 0
|
PHP
laravel创建admin文件夹,里边的indexController怎么写
laravel创建admin文件夹,里边的indexController怎么写
184 0
thinkphp5常用模板标签使用方法
thinkphp5常用模板标签使用方法
240 0
|
PHP
在smarty模板中使用PHP函数的方法
sample1 复制代码 代码如下: 那如果使用像iconv这样的有三个参数的函数该怎么写呢?如果写成: sample 2 复制代码 代码如下: 一执行就会发现显示error信息。 因此研究一下就会发现,起始在smarty模板页的套用函数用法中,以smaple 1来说,trim的前面$Row->colname其实就是trim的第一个参数,中间用|这个符号串接; 那假设要使用像iconv有三个参数的函数的话,就要写成: sample 3 复制代码 代码如下: 也就是 函数第一个参数|函数:第二个参数:第三个参数。
1183 0