![]() |
Smarty-2.6.24.tar.gz | 2010-11-11 18:20 | 149K | |
![]() |
Smarty-2.6.24.zip | 2010-11-11 18:20 | 188K | |
![]() |
Smarty-2.6.25.tar.gz | 2010-11-11 18:20 | 149K | |
![]() |
Smarty-2.6.25.zip | 2010-11-11 18:20 | 188K | |
![]() |
Smarty-2.6.26.tar.gz | 2010-11-11 18:20 | 149K | |
![]() |
Smarty-2.6.26.zip | 2010-11-11 18:20 | 188K | |
![]() |
Smarty-2.6.27.tar.gz | 2012-09-25 14:43 | 151K | |
![]() |
Smarty-2.6.27.zip | 2012-09-25 14:43 | 190K | |
![]() |
Smarty-2.6.28.tar.gz | 2013-10-01 15:24 | 151K | |
![]() |
Smarty-2.6.28.zip | 2013-10-01 15:24 | 190K | |
![]() |
Smarty-3.0.0.tar.gz | 2010-11-11 21:01 | 130K | |
![]() |
Smarty-3.0.0.zip | 2010-11-11 21:01 | 191K | |
![]() |
Smarty-3.0.1.tar.gz | 2010-11-12 10:09 | 130K | |
![]() |
Smarty-3.0.1.zip | 2010-11-12 10:09 | 191K | |
![]() |
Smarty-3.0.2.tar.gz | 2010-11-12 20:26 | 130K | |
![]() |
Smarty-3.0.2.zip | 2010-11-12 20:26 | 191K | |
![]() |
Smarty-3.0.3.tar.gz | 2010-11-13 08:33 | 130K | |
![]() |
Smarty-3.0.3.zip | 2010-11-13 08:33 | 190K | |
![]() |
Smarty-3.0.4.tar.gz | 2010-11-13 14:34 | 130K | |
![]() |
Smarty-3.0.4.zip | 2010-11-13 14:34 | 190K | |
![]() |
Smarty-3.0.5.tar.gz | 2010-11-20 22:02 | 131K | |
![]() |
Smarty-3.0.5.zip | 2010-11-20 22:02 | 191K | |
![]() |
Smarty-3.0.6.tar.gz | 2010-12-13 10:54 | 132K | |
![]() |
Smarty-3.0.6.zip | 2010-12-13 10:54 | 192K | |
![]() |
Smarty-3.0.7.tar.gz | 2011-02-11 17:09 | 132K | |
![]() |
Smarty-3.0.7.zip | 2011-02-11 17:09 | 192K | |
![]() |
Smarty-3.0.8.tar.gz | 2011-06-03 15:29 | 147K | |
![]() |
Smarty-3.0.8.zip | 2011-06-03 15:29 | 206K | |
![]() |
Smarty-3.0.9.tar.gz | 2011-09-16 13:17 | 147K | |
![]() |
Smarty-3.0.9.zip | 2011-09-16 13:17 | 207K | |
![]() |
Smarty-3.0b7.tar.gz | 2010-11-11 18:20 | 127K | |
![]() |
Smarty-3.0b7.zip | 2010-11-11 18:20 | 207K | |
![]() |
Smarty-3.0b8.tar.gz | 2010-11-11 18:20 | 125K | |
![]() |
Smarty-3.0b8.zip | 2010-11-11 18:20 | 183K | |
![]() |
Smarty-3.0rc1.tar.gz | 2010-11-11 18:20 | 119K | |
![]() |
Smarty-3.0rc1.zip | 2010-11-11 18:20 | 174K | |
![]() |
Smarty-3.0rc2.tar.gz | 2010-11-11 18:20 | 122K | |
![]() |
Smarty-3.0rc2.zip | 2010-11-11 18:20 | 177K | |
![]() |
Smarty-3.0rc3.tar.gz | 2010-11-11 18:20 | 123K | |
![]() |
Smarty-3.0rc3.zip | 2010-11-11 18:20 | 178K | |
![]() |
Smarty-3.1.0.tar.gz | 2011-09-16 13:19 | 178K | |
![]() |
Smarty-3.1.0.zip | 2011-09-16 13:19 | 249K | |
![]() |
Smarty-3.1.1.tar.gz | 2011-09-23 10:19 | 184K | |
![]() |
Smarty-3.1.1.zip | 2011-09-23 10:19 | 256K | |
![]() |
Smarty-3.1.2.tar.gz | 2011-10-03 16:04 | 186K | |
![]() |
Smarty-3.1.2.zip | 2011-10-03 16:06 | 258K | |
![]() |
Smarty-3.1.3.tar.gz | 2011-10-07 12:14 | 188K | |
![]() |
Smarty-3.1.3.zip | 2011-10-07 12:14 | 259K | |
![]() |
Smarty-3.1.4.tar.gz | 2011-10-19 15:23 | 188K | |
![]() |
Smarty-3.1.4.zip | 2011-10-19 15:23 | 259K | |
![]() |
Smarty-3.1.5.tar.gz | 2011-11-14 12:56 | 191K | |
![]() |
Smarty-3.1.5.zip | 2011-11-14 12:56 | 263K | |
![]() |
Smarty-3.1.6.tar.gz | 2011-12-01 10:32 | 191K | |
![]() |
Smarty-3.1.6.zip | 2011-12-01 10:32 | 263K | |
![]() |
Smarty-3.1.7.tar.gz | 2011-12-19 17:07 | 193K | |
![]() |
Smarty-3.1.7.zip | 2011-12-19 17:07 | 265K | |
![]() |
Smarty-3.1.8.tar.gz | 2012-02-20 11:24 | 195K | |
![]() |
Smarty-3.1.8.zip | 2012-02-20 11:24 | 266K | |
![]() |
Smarty-3.1.9.tar.gz | 2012-06-08 16:35 | 197K | |
![]() |
Smarty-3.1.9.zip | 2012-06-08 16:35 | 268K | |
![]() |
Smarty-3.1.10.tar.gz | 2012-06-09 11:54 | 197K | |
![]() |
Smarty-3.1.10.zip | 2012-06-09 11:54 | 268K | |
![]() |
Smarty-3.1.11.tar.gz | 2012-06-30 17:18 | 198K | |
![]() |
Smarty-3.1.11.zip | 2012-06-30 17:18 | 269K | |
![]() |
Smarty-3.1.12.tar.gz | 2012-09-25 14:43 | 198K | |
![]() |
Smarty-3.1.12.zip | 2012-09-25 14:43 | 270K | |
![]() |
Smarty-3.1.13.tar.gz | 2013-01-15 20:00 | 199K | |
![]() |
Smarty-3.1.13.zip | 2013-01-15 20:00 | 271K | |
![]() |
Smarty-3.1.14.tar.gz | 2013-06-27 22:13 | 200K | |
![]() |
Smarty-3.1.14.zip | 2013-06-27 22:13 | 272K | |
![]() |
Smarty-3.1.15.tar.gz | 2013-10-01 15:24 | 201K | |
![]() |
Smarty-3.1.15.zip | 2013-10-01 15:24 | 272K | |
![]() |
Smarty-3.1.16.tar.gz | 2013-12-19 17:53 | 203K | |
![]() |
Smarty-3.1.16.zip | 2013-12-19 17:53 | 275K | |
![]() |
Smarty-3.1.17.tar.gz | 2014-03-12 15:57 | 204K | |
![]() |
Smarty-3.1.17.zip | 2014-03-12 15:57 | 276K | |
![]() |
Smarty-3.1.18.tar.gz | 2014-04-07 14:37 | 204K | |
![]() |
Smarty-3.1.18.zip | 2014-04-07 14:37 | 276K | |
![]() |
Smarty-3.1.19.tar.gz | 2014-07-01 01:15 | 203K | |
![]() |
Smarty-3.1.19.zip | 2014-07-01 01:15 | 276K | |
![]() |
Smarty-3.1.20.tar.gz | 2014-10-10 09:39 | 203K | |
![]() |
Smarty-3.1.20.zip | 2014-10-10 09:39 | 276K | |
![]() |
Smarty-3.1.21.tar.gz | 2014-10-18 23:30 | 203K | |
![]() |
Smarty-3.1.21.zip | 2014-10-18 23:30 | 276K | |
![]() |
Smarty-3.1rc1.tar.gz | 2011-06-27 12:01 | 178K | |
![]() |
Smarty-3.1rc1.zip | 2011-06-27 12:01 | 249K | |
![]() |
Smarty-stable.tar.gz | 2014-10-18 23:30 | 203K | |
![]() |
Smarty-stable.zip | 2014-10-18 23:30 | 276K | |
![]() |
SmartyTrademark.pdf | 2010-11-11 18:20 | 65K | |
![]() |
docs/ | 2013-06-27 22:13 | – | |
![]() |
sampleapp.zip | 2011-11-22 15:41 | 5.3K | |
|
php smarty
Php Smarty template lib
It is perfect template lib for php developers, Easy to develop specific projects and increase speed of the project.
Code Example :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Example 7.17. Simple {include} example <html> <head> <title>{$title}</title> </head> <body> {include file='page_header.tpl'} {* body of template goes here, the $tpl_name variable is replaced with a value eg 'contact.tpl' *} {include file="$tpl_name.tpl"} {include file='page_footer.tpl'} </body> </html> |
Of course you should install your smarty to your server.
Quick Smarty Install
In Debian Etch:
1 2 3 |
apt-get install smarty edit php.ini (mine's at /etc/php5/apache2 and set include_path to ".:/usr/share/php:/usr/share/pear:/usr/share/php/smarty/libs" restart apache2 with /etc/init.d/apache2 restart |
Now you have a Smarty install. To use it, you’ll need PHP code to drive Smarty. I’ll include a sample bit of PHP code that I was working on with Mike A:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<?php require("Smarty.class.php"); $smarty = new Smarty(); $dir = '/var/www-sites.d/malborn.kutayzorlu.com'; $smarty->template_dir = $dir . '/smarty/templates'; $smarty->compile_dir = $dir . '/smarty/templates_c'; $smarty->cache_dir = $dir . '/smarty/cache'; $smarty->config_dir =$dir . '/smarty/configs'; $content = implode('', file($dir . "/index.txt")); $head = implode('', file($dir . "/head.txt")); $footer = implode('', file($dir . "/footer.txt")); $navbar = implode('', file($dir . "/navbar.txt")); if(preg_match('/<title>(.*?)<\/title>/is', $head, $m)) { $title = $m[1]; } else { $title = "Default Title"; } $smarty->assign("title", $title); $smarty->assign("head", $head); $smarty->assign("footer", $footer); $smarty->assign("content", $content); $smarty->assign("navbar", $navbar); $smarty->display("default.tpl"); ?> |
Now, for Smarty to operate you need to supply some directories (i.e. template_dir, compile_dir, cache_dir, config_dir). compile_dir and cache_dir need to writeable by the web server user so in Debian something like:
1 2 3 4 5 6 7 8 9 10 11 12 |
#!/bin/bash DIR=/var/www-sites.d/malborn.kutayzorlu.com mkdir $DIR/smarty mkdir $DIR/smarty/cache mkdir $DIR/smarty/configs mkdir $DIR/smarty/templates mkdir $DIR/smarty/templates_c sudo chown -r :www-data $DIR/smarty/cache sudo chown -r :www-data $DIR/smarty/templates_c |
Write default.tpl into $DIR/smarty/templates/default.tpl . For example,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> {$head} <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <link rel="stylesheet" type="text/css" href="default.css" media="screen"/> <title>{$title}</title> </head> <body> <div class="body"> <div class="title">{$title}</div> <div class="subnav"> <h1>Navigation</h1> {$navbar} </div> <div class="main"> {$content} </div> <div class="footer"> {$footer} </div> </div> </body> </html> |
* 1. Download smarty packages
* 2. Extract them somewhere else
* 3 . Write extration path to inside of php.ini file, include_path
* 4. then restart httpd
5 . Create php file , (write template folder path )
6. Create Template file .
7.
Now, moving from here would be something like:
1. Writing code to check for a navbar.txt in the current direction. If not found, stuff navbar Smarty tag with “Back up a level” that moves up one subdirectory (i.e. go to /directory/index.html if you were are /directory/author.html, and go to /index.html when you were are /directory/index.html, etc.)
2. Could proceed by designing a number of templates in Smarty for the same basic content – i.e. skin-bluesteel.tpl and then providing a user interface to switch templates.
3. Perhaps eliminate filesystem reliance and put URL’s into a database.
Map /directory to /directory/index.html, similar with /.
If not in database, display a generic 404 error. You can develop this script by calling it like
/database-script-were-writing.php/directory/index.html and then looking into
PATH_INFO from the server which will contain /directory/index.html .
Once you have this perfected, you set up apache with something like
“Alias / /var/www-sites.d/malborn.kutayzorlu.com/database-script-were-writing.php”
and everything should pretty much just work.