Blogroll

photoshop cs6 html 5 css php seo backlinks

adsense

Monday, 24 February 2014

Variable at Configuration File: Smarty Variable

Smarty Variable Step by Step Tutorial - Part 4: We can store variables at configuration file. For this job, we must create a folder named configs within root application (example, www/test/smarty). So, we have www/test/smarty/configs.
Create a configuration file with conf extension, such as "setting.conf". Enter following sample code:
1pageTitle = "Hello, World"
2bodyColor = "#EAEAEA"
Next, build template by create a file named "test.tpl" within template. Enter following code
01{config_load file="setting.conf"}
02<html>
03  <head>
04    <title>{#pageTitle#}</title>
05  </head>
06  <body bgcolor="{#bodyColor#}">
07    id : {$contact->id} <br>
08    name : {$contact->name} <br>   
09    email : {$contact->email} <br>   
10    phone : {$contact->phone} <br>   
11  </body>
12</html>
Create a file named "test.php" enter following code:

01<?php
02require 'Smarty/libs/Smarty.class.php';
03 
04class Contacts{
05  var $id   = 1;
06  var $name = 'wiwit';
07  var $email = 'wsiswoutomo at yahoo dot com';
08  var $phone = '123456789';
09}
10 
11$contact = new Contacts;
12 
13$smarty = new Smarty;
14 
15$smarty->assign('contact',$contact);
16$smarty->display('test.tpl');
17?>

0 comments:

Post a Comment