Cách cài đặt Smarty trên Windows. I wish I had this info when I started, the documentation is geared towards *nix and is confusing but it was a good learning experience.
Hopefully, Monte or the Smarty folks will include this info on their web or more importantly in the installation documentation in the Smarty download.
Installing Smarty in Windows
This document assumes that your webserver and php5 is running.
Download Smarty - http://smarty.php.net
Installation - Windows, IIS/Apache, PHP5
Extract files, rename Smarty.x.x.x to smarty (suggest OUTSIDE of your www root!)
Example: d:\smarty
Run phpinfo.php to find out your php.ini location
Edit php.ini's include_path and add the location of the libs folder.
example: include_path = ".;d:\smarty\libs"
Restart IIS/Apache
Setup these two folders INSIDE your www root:
(wwwroot)/smarty/templates (this is where your templates will go)
(wwwroot)/smarty/configs
Setup these two folders OUTSIDE of your www root:
d:/smarty/templates_c
d:/smarty/cache
Setup security settings for the webserver to write to these four folders
In (wwwroot) create index.php and in (wwwroot)/smarty/templates/index.tpl with the following code:
index.php:
Now open index.php in your web browser (requested from your webserver)
http://webserver/index.php
You can work this out to a referenced script/class:
smarty_connect.php:
<?php
require('smarty_connect.php');
$smarty = new smarty_connect;
$smarty->assign('name','Ned');
$smarty->display('index.tpl');
?>
index.tpl:
<html>
<body>
Hello, {$name}!
</body>
</html>
If you are getting an error that Smarty.class.php isn't found chances are that your include_path isn't correct or you didn't edit the one that the webserver is using, check your phpinfo.php!
Hopefully, Monte or the Smarty folks will include this info on their web or more importantly in the installation documentation in the Smarty download.
Installing Smarty in Windows
This document assumes that your webserver and php5 is running.
Download Smarty - http://smarty.php.net
Installation - Windows, IIS/Apache, PHP5
Extract files, rename Smarty.x.x.x to smarty (suggest OUTSIDE of your www root!)
Example: d:\smarty
Run phpinfo.php to find out your php.ini location
Edit php.ini's include_path and add the location of the libs folder.
example: include_path = ".;d:\smarty\libs"
Restart IIS/Apache
Setup these two folders INSIDE your www root:
(wwwroot)/smarty/templates (this is where your templates will go)
(wwwroot)/smarty/configs
Setup these two folders OUTSIDE of your www root:
d:/smarty/templates_c
d:/smarty/cache
Setup security settings for the webserver to write to these four folders
In (wwwroot) create index.php and in (wwwroot)/smarty/templates/index.tpl with the following code:
index.php:
<?php
// load Smarty library
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = 'd:/inetpub/wwwroot/smarty/templates';
$smarty->config_dir = ' d:/inetpub/wwwroot/smarty/config';
$smarty->cache_dir = 'd:/smarty/smarty_cache';
$smarty->compile_dir = 'd:/smarty/smarty_templates_c';
$smarty->assign('name','fish boy!');
$smarty->display('index.tpl');
?>
index.tpl
<html>
<body>
Hello, {$name}!
</body>
</html>
// load Smarty library
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = 'd:/inetpub/wwwroot/smarty/templates';
$smarty->config_dir = ' d:/inetpub/wwwroot/smarty/config';
$smarty->cache_dir = 'd:/smarty/smarty_cache';
$smarty->compile_dir = 'd:/smarty/smarty_templates_c';
$smarty->assign('name','fish boy!');
$smarty->display('index.tpl');
?>
index.tpl
<html>
<body>
Hello, {$name}!
</body>
</html>
Now open index.php in your web browser (requested from your webserver)
http://webserver/index.php
You can work this out to a referenced script/class:
smarty_connect.php:
<?php
// load Smarty library
require('Smarty.class.php');
class smarty_connect extends Smarty
{
function smarty_connect()
{
// Class Constructor.
// These automatically get set with each new instance.
$this->Smarty();
$this->template_dir = ' d:/inetpub/wwwroot/smarty/templates';
$this->config_dir = ' d:/inetpub/wwwroot/smarty/config';
$this->compile_dir = 'd:/smarty/templates_c';
$this->cache_dir = 'd:/smarty/cache';
$this->assign('app_name', 'Intranet');
}
}
?>
index.php:// load Smarty library
require('Smarty.class.php');
class smarty_connect extends Smarty
{
function smarty_connect()
{
// Class Constructor.
// These automatically get set with each new instance.
$this->Smarty();
$this->template_dir = ' d:/inetpub/wwwroot/smarty/templates';
$this->config_dir = ' d:/inetpub/wwwroot/smarty/config';
$this->compile_dir = 'd:/smarty/templates_c';
$this->cache_dir = 'd:/smarty/cache';
$this->assign('app_name', 'Intranet');
}
}
?>
<?php
require('smarty_connect.php');
$smarty = new smarty_connect;
$smarty->assign('name','Ned');
$smarty->display('index.tpl');
?>
index.tpl:
<html>
<body>
Hello, {$name}!
</body>
</html>
If you are getting an error that Smarty.class.php isn't found chances are that your include_path isn't correct or you didn't edit the one that the webserver is using, check your phpinfo.php!
| Ứng dụng swfobject để thể hiện Flash media: video, music, flash, flv < Lùi | Tiếp theo > Hướng dẫn cài đặt Smarty trên hệ điều hành Linux |
|---|
Tags:
Tin mới hơn:
- 07/05/2009 21:23 - Nhúng Flash với SWFobject và AC_FL_RunContent
- 20/04/2009 22:43 - Thư viện đồ họa GD Library
- 19/04/2009 13:43 - Cài đặt Web Server XAMPP trên Linux
- 09/04/2009 18:12 - Thiết kế web với các kiểu Menu, Tab CSS, jQuery
- 04/04/2009 20:49 - Ứng dụng swfobject để thể hiện Flash media: video, music, flash, flv
Tin cũ hơn:
- 04/03/2009 22:33 - Hướng dẫn cài đặt Smarty trên hệ điều hành Linux
- 28/02/2009 23:07 - Cấu hình file .htaccess để thêm Addon Domain
- 27/02/2009 11:06 - Một số bảng mã thông dụng
- 10/01/2009 20:34 - Làm thế nào để thiết kế lại trang web của bạn
- 05/01/2009 08:13 - Giới thiệu các dịch vụ dùng để tạo trang web bắt đầu - StartPage
Download Game bóng đá PES8 Việt Nam
Tải game bóng đá FiFa 09
Tải game Dragon ball Z - 7 viên ngọc rồng
Tải Game Bóng Đá Pro Evolution Soccer 6 Việt Nam
Download PES 2011 patch Việt Nam PESVN
Tải Game Bóng Đá FIFA 2009 RIP 1 CD
Download Pro Evolution Soccer 2011
Download Game THE SIMS 3
Tải Game bóng đá PES 2009
Download PES 2011 demo
Thay đổi màn hình đăng nhập Windows 7 bằng tay
Một số hàm hay dùng trong JavaScript
Kiểm soát hoàn toàn trỏ chuột bằng bàn phím với NeatMouse
Choáng với concept của Windows Phone 8
Những đặc điểm ưu việt của Windows Phone
Ứng dụng gọi điện VoIP Viber sắp có mặt trên Windows Phone
Game Diablo 3 sắp có mặt trên Windows Phone Marketplace
37 trang css & xhtml web template miễn phí tuyệt đẹp
Những điều cơ bản cần biết về bàn phím chơi game - Gaming Keyboard
L.A. Noire: The Complete Edition - THETA [Full ISO/Action/2011] [13.37GB]
Download 7554 demo
Download Game PC, cập nhật liên tục (torrent)
PES 2012 ra mắt bản mở rộng đầu tiên vào 11/10
PES2012 - Full version - Ngôn ngữ và bình luận tiếng Anh
PES2012 - Blurry disable làm mịn đồ họa
PES 2011 PATCH 4.1 - TRANSFER UPDATE - RELEASED
Bộ sưu tập free PrestaShop Themes phần 3
Bộ sưu tập theme Prestashop miễn phí phần 2
Top 10 Free PrestaShop Themes
Download Prestashop 1.5
Download PrestaShop 1.4
Bổ sung Memcached vào PrestaShop 1.4
Hướng dẫn tích hợp Ngân Lượng vào PrestaShop
Sửa lỗi invalid carrier or no carrier selected trong PrestaShop
Cài đặt PrestaShop
Thiết kế giao diện PrestaShop Theme
Hướng dẫn cài đặt themes trong PrestaShop
Hướng dẫn cách thêm ngôn ngữ cho PrestaShop
Bộ sưu tập Giao diện Premium PrestaShop Themes chuyên nghiệp
Giới thiệu về website thương mại điện tử 2.0 Prestashop
Cấu hình đường dẫn thân thiện với Joomsef


