ผมหาทางติดตั้ง Smarty 3.1.7 เพื่อให้ใช้งานได้กับ CodeIgniter 2.1.0 ได้ โดยมีขั้นดังนี้
ดาวน์โหลดและติดตั้ง CodeIgniter ตามปกติ การติดตั้ง Smarty จะดำเนินการโดยใช้ Ci-Smarty ที่พัฒนาขึ้นโดยคุณ Dwayne Charrington ให้ดาวน์โหลดและติดตั้งลงใน CodeIgniter ในข้อ 1. แล้วให้ทำการทดสอบว่าสามารถใช้งาน Smarty ได้จริง เนื่องจากในขณะที่เขียนบทความนี้ Smarty ที่ิติดตั้งใน Ci-Smarty เป็นเวอร์ชัน 3.1.1 เราจึงต้องมีการแก้ไขปรับแก้ไฟล์ โดยโครงสร้างไฟล์ของ Ci-Smarty มีดังภาพข้างล่างนี้
เราต้องปรับแก้ 3 [...]
ผมบังเิอิญไปเจอวิธีการที่จะเรียก Smarty library ที่น่าสนใจ สะดวกมากเวลาที่กำลังพัฒนาโปรแกรม เพราะไม่ต้องระบุ path เลย แต่เมื่อพัฒนาโปรแกรมเสร็จแล้วก็ควรแก้ไข path ให้ถูกต้องครับ
<?php // SMARTY Section define(‘SMARTY_DIR’,str_replace(“\”,”/”,getcwd()).’/Smarty-2.6.19/libs/’); require_once(SMARTY_DIR . ‘Smarty.class.php’); $smarty = new Smarty(); $smarty->template_dir = str_replace(“\”,”/”,getcwd()).’/templates/’; $smarty->compile_dir = str_replace(“\”,”/”,getcwd()).’/templates_c/’; $smarty->config_dir = str_replace(“\”,”/”,getcwd()).’/configs/’; $smarty->cache_dir = str_replace(“\”,”/”,getcwd()).’/cache/’; //** un-comment the following line to show the debug console //$smarty->debugging = true; ?>
Tags
.htaccess Apache blogspot CentOS codeigniter CSS domain name driver Drupal Flickr Hotmail HTML internet law linux Mac OS X mailing list mailman MICT mod_rewrite monitor MSL MySQL name server Network PHP Postfix Security Smarty sony Spammail SPF theme TLS traffic log Universiade UTF-8 UTF8 vbulletin Wordpress การเมือง จตุคาม รูปภาพ สถิติ เรารักในหลวง
