DESAIN TEMPLATE dan PEMROGRAMAN WEB Mengunakan XHTML|CSS|PHP|Smarty|MySQL
http://cristiandarie.ro/php-mysql-ecommerce-2
2011©Zainal Abidin
Web Template Design n Web Programming June 13, 2011
2
DESAIN FOLDER dan FILE [C:/xampp/htdocs/tshirtshop/include/config.php]
NO. REALITA SKRIP 1 C:/xampp/htdocs/tshirtshop SITE_ROOT 2 C:/xampp/htdocs/tshirtshop/presentation PRESENTATION_DIR 3 C:/xampp/htdocs/tshirtshop/libs/smarty1 SMARTY_DIR 4 C:/xampp/htdocs/tshirtshop/presentation/templates TEMPLATE_DIR 5 C:/xampp/htdocs/tshirtshop/presentation/templates_c COMPILE_DIR 6 C:/xampp/htdocs/tshirtshop/include/configs CONFIG_DIR
HALAMAN MUKA WEB [C:/xampp/htdocs/tshirtshop/index.php]
NO. KODE INTERPRETASI TEKNOLOGI 1 <?
?> Tag PHP PHP
2 require_once 'include/config.php'; Memanggil file config.php yang berada di C:/xampp/htdocs/tshirtshop/include
PHP
3 require_once PRESENTATION_DIR . 'application.php';
Memanggil file application.php yang berada di C:/xampp/htdocs/tshirtshop/ presentation
PHP
4 $application = new Application(); Mendefinisikan variable baru untuk kelas Application, yaitu: application
PHP
5 $application->display('store_front.tpl'); Menampilkan file template web, yaitu: store_front.tpl yang berada di C:/xampp/htdocs/tshirtshop/ presentation
Smarty
1 Hasil ekstraksi dari: http://www.smarty.net/files/Smarty-3.0.8.zip
Web Template Design n Web Programming June 13, 2011
3
PRESENTATION-TIER [C:/xampp/htdocs/tshirtshop/ presentation/application.php]
NO. KODE INTERPRETASI TEKNOLOGI 1 <?
?> Tag PHP PHP
2 require_once SMARTY_DIR. 'Smarty.class.php'; Memanggil file Smarty.class.php yang berada di C:/xampp/htdocs/tshirtshop/libs/smarty
PHP
3 class Application extends Smarty { }
Mendefinisikan kelas baru dgn nama dan Application memanggil kelas Smarty dari file Smarty.class.php
PHP
4 public function _construct() { }
Memanggil fungsi dari kelas Smarty, yaitu: _construct()
PHP
5 parent::_construct(); Mengeksekusi fungsi _construct() PHP 6 $this->template_dir = TEMPLATE_DIR; Mengubah direktori template menjadi
C:/xampp/htdocs/tshirtshop/presentation/templates #default/mula-mula: null
PHP
7 $this->compile_dir = COMPILE_DIR; Mengubah direktori compile menjadi C:/xampp/htdocs/tshirtshop/presentation/templates_c #default/mula-mula: null
PHP
8 $this->config_dir = CONFIG_DIR; Mengubah direktori config menjadi C:/xampp/htdocs/tshirtshop/ include/configs #default/mula-mula: null
PHP
Web Template Design n Web Programming June 13, 2011
4
C:/xampp/htdocs/tshirtshop/
presentation/application.php
http://localhost/tshirtshop/