ZF0.15成功整合Smarty2.6.14!傻瓜化教程
来源:互联网 发布:淘宝差评怎么写 编辑:程序博客网 时间:2024/06/14 18:00
虽然论坛上已经有ZF整合Smarty的文章,不过可能是我水平太菜,老是试验不成功,不过今晚,就是现在啦,在自己的机子上,终于成功整合ZF+Smarty,以前是个人的小小心得...[/color]
1:目录结构:
+ www
- zf
--Application
Controllers
Models
---Views
Cache
Configs
Tpl
Tpl_c
--library
+Zend
2. Apache启用Rewrite
3. .htaccess文件的内容
RewriteEngine on
RewriteRule !/.(js|ico|gif|jpg|png|css)$ index.php
php_value include_path "../library"
4.配置Apache,zf/www为网站根目录
5.文件位置:
zf/www : 放置 .htaccess index.php
Application/Controllers :放置IndexController.php
Application/Views : 放置 Tpl,Tpl_c,Cache,Configs四个文件夹..Tpl文件夹里放模板文件..
6.文件内容:
zf/www/index.php:
<?php
include 'Zend.php';
include 'Zend/View/Smarty/Smarty.class.php';
define('SITE','../Application/Views/');
$tpl=new Smarty;
$tpl->template_dir = SITE.'Tpl';
$tpl->compile_dir = SITE.'Tpl_c';
$tpl->cache_dir = SITE.'Cache';
$tpl->config_dir = SITE.'Configs';
Zend::register('tpl',$tpl);
function __autoload($class) {
Zend::loadClass($class);
}
$router = new Zend_Controller_RewriteRouter();
$controller = Zend_Controller_Front::getInstance();
$controller->setRouter($router);
$controller->setControllerDirectory('../Application/Controllers');
$controller->dispatch();
?>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Application/Controllers/IndexController.php
<?php
class IndexController extends Zend_Controller_Action {
public function indexAction() {
$tpl=Zend::registry('tpl');
$tpl->assign('title','我是誰啊');
$tpl->assign('content','我是從哪裡來的呀');
$tpl->display('index.html');
}
public function noRouteAction() {
$this->_redirect('./');
}
}
?>
模板文件就萝卜青菜了....呵呵...教程到些结束...
1:目录结构:
+ www
- zf
--Application
Controllers
Models
---Views
Cache
Configs
Tpl
Tpl_c
--library
+Zend
2. Apache启用Rewrite
3. .htaccess文件的内容
RewriteEngine on
RewriteRule !/.(js|ico|gif|jpg|png|css)$ index.php
php_value include_path "../library"
其实一样的。
主要是你没注意看。
我一直也是用ZF和Smarty结合的!
我的index.php也是这样的。
把V设置成放摸板的地方。
PHP代码如下:
主要是你没注意看。
我一直也是用ZF和Smarty结合的!
我的index.php也是这样的。
把V设置成放摸板的地方。
PHP代码如下:
<?
set_include_path('../library');
include 'Zend.php';
include 'Smarty/Smarty.class.php';
include './Application/Models/Datebase.php'; //数据库操作类
include'../FCKeditor/fckeditor.php'; //在线编辑器
function __autoload($class)
{
Zend::loadClass($class);
}
$db = new Database();
Zend::register('db', $db); // 注册数据库超作对象到对象仓库
$tpl= new Smarty();
$tpl->caching=false; //缓存
$tpl->debugging=false;
$tpl->template_dir="./Application/Views";
$tpl->compile_dir="./Application/Views/Views_c";
$tpl->cache_dir = "./Application/Views/Cache";
Zend::register('tpl',$tpl);
$oFCKeditor = new FCKeditor('FCKeditor');
Zend::register('oFCKeditor',$oFCKeditor);
$router = new Zend_Controller_RewriteRouter();
$controller = Zend_Controller_Front::getInstance();
$controller->setRouter($router);
$controller->setControllerDirectory('./Application/controllers');
$controller->dispatch();
?>
4.配置Apache,zf/www为网站根目录
5.文件位置:
zf/www : 放置 .htaccess index.php
Application/Controllers :放置IndexController.php
Application/Views : 放置 Tpl,Tpl_c,Cache,Configs四个文件夹..Tpl文件夹里放模板文件..
6.文件内容:
zf/www/index.php:
<?php
include 'Zend.php';
include 'Zend/View/Smarty/Smarty.class.php';
define('SITE','../Application/Views/');
$tpl=new Smarty;
$tpl->template_dir = SITE.'Tpl';
$tpl->compile_dir = SITE.'Tpl_c';
$tpl->cache_dir = SITE.'Cache';
$tpl->config_dir = SITE.'Configs';
Zend::register('tpl',$tpl);
function __autoload($class) {
Zend::loadClass($class);
}
$router = new Zend_Controller_RewriteRouter();
$controller = Zend_Controller_Front::getInstance();
$controller->setRouter($router);
$controller->setControllerDirectory('../Application/Controllers');
$controller->dispatch();
?>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Application/Controllers/IndexController.php
<?php
class IndexController extends Zend_Controller_Action {
public function indexAction() {
$tpl=Zend::registry('tpl');
$tpl->assign('title','我是誰啊');
$tpl->assign('content','我是從哪裡來的呀');
$tpl->display('index.html');
}
public function noRouteAction() {
$this->_redirect('./');
}
}
?>
模板文件就萝卜青菜了....呵呵...教程到些结束...
- ZF0.15成功整合Smarty2.6.14!傻瓜化教程
- smarty2
- zf0 hack
- PyQt5.6 + pycharm 配置 以及 pyinstaller 生成exe 傻瓜教程 100%成功
- 只有傻瓜才会成功
- HLSL傻瓜教程
- Desire降级傻瓜教程
- Git傻瓜教程
- Ecotect2011傻瓜教程
- opencv安装傻瓜教程
- IBE傻瓜教程
- ReactJS 傻瓜教程
- ReactJS 傻瓜教程
- Flux 傻瓜教程
- AJAX单元测试傻瓜教程
- Git傻瓜教程
- Jenkins安装傻瓜教程
- MFC傻瓜式教程
- 通用ShellCode深入剖析
- 在同一个进程空间运行两个程序
- 用C编写Windows服务程序的五个步骤
- 窗口切换分割详解
- 用VC存取数据库中的大对象
- ZF0.15成功整合Smarty2.6.14!傻瓜化教程
- 一个简易网络嗅探器的实现
- Smarty variable modifiers(变量调节器)----首字大写(Capitalize)
- VC++中如何遍历整个目录树查找文件
- 推荐阅读Java并发性领域编程最值得一读的力作《JAVA并发编程实践》
- VC++动态链接库((DLL)编程深入浅出((一)
- VC++动态链接库((DLL)编程深入浅出((二)
- Linux 距离个人桌面有多远?
- VC++实现文件夹时间属性的获取与更改