Blogroll

photoshop cs6 html 5 css php seo backlinks

adsense

Monday, 24 February 2014

Start Smarty Template: My First Smarty

Smarty Template Step By Step Tutorial - Part 3: After create folder needed to operate Smarty template at previous post, in this post, we try to test it. We want to create a page to show simple hello text. Let's do it.
First, we do with template file. Create a file named "test.tpl" within template folder. Enter following code:
1<html>
2  <head>
3    <title>{$title}</title>
4  </head>
5  <body>
6    {$hello}
7  </body>
8</html>
Next, create a php file named "test.php" within www/test/smarty. Enter following code:
1<?php
2require 'Smarty/libs/Smarty.class.php';
3 
4$smarty = new Smarty;
5 
6$smarty->assign('title','Hello World');
7$smarty->assign('hello','Hello World, this is my first Smarty!');
8$smarty->display('test.tpl');
9?>
This is our structure:
Now, test it by pointing your browser to http://localhost/test/smarty/test.php. You may get like this:
 

0 comments:

Post a Comment