PHP学习笔记
php

function smarty_block_dynamic($param, $content, &$smarty) 
{
    return $content;
}

$smarty->register_block('dynamic', 'smarty_block_dynamic', false);
if(!$smarty->is_cached("test.tpl"))
{
        $smarty->assign("nowTime",date("Y-m-d H:i:
Smarty | 评论(3) | 引用() | 阅读(-) | admin | 2008-05-15 18:40:12
在 Smarty.class.php 里加上这个函数就可以了 

PHP代码
/* 自定义生成html文件 */     
function MakeHtmlFile($file_name, $c) {  //目录不存在就创建     
      if (!file_exists (dirname($file_name))) {     
         if ([email protected] (dirname($file_name), 0777)) {     
               die($file_name."目录创建失败!");     
      
Smarty | 评论(0) | 引用() | 阅读(-) | admin | 2008-04-28 17:54:42
利用PHP与Smarty模板技术生成分页静态页面的代码:
<?php
//smarty.php
//create html file use smarty template
[email protected]
//2007-07-27 11:15

require_once("classes/Smarty.class.php"); //smarty文件
require_once("config.php"); //配置文件
require_once("mysql_class.php"); //数据库连接文件
Smarty | 评论(4) | 引用() | 阅读(-) | admin | 2008-04-28 17:54:09
Smarty的缓存操作

Smarty的缓存*作
2007-03-24 11:51:43
一、使用缓存
要开启smarty的缓存,只需将caching设为true,并指定cache_dir即可.
使用cache_lefetime指定缓存生存时间,单位为秒
要对相同页面生成多个不同的缓存,在display或fetch中加入第二参数cache_id,如$smarty->display('index.tpl',$my_cache_id);此特性可用于对不同的$_GET进行不同的缓存

二、清除缓存

clear_all_cache();//清除所有缓存
clear_ca
Smarty | 评论(0) | 引用() | 阅读(-) | admin | 2008-04-28 09:12:55
     smarty的庞大身躯一直为人所诟病,但其功能"强大"却是不得不令人叹服. 对模板引擎来说,缓存是必不可少的.
     smarty在这方面同样是优秀的,它拥有众多令人可喜的功能: 1)可在同一程序中对不同模板文件使用不同的缓存时间 2)可使用不同的cache_id实现同一模板的不同缓存(想起asp.net的根椐$request缓存),这对统一入口的程序很有用,可以根椐url来生成不同的缓存 3)可使用$cache_handler_func来使用自定义缓存处理函数 4)可控性强,可对同一文件的部分设定是否缓存 以下内容主要是对局部缓存所作的探讨. 局部缓存的作
Smarty | 评论(0) | 引用() | 阅读(-) | admin | 2008-04-28 09:10:51