Your SlideShare is downloading. ×
Smarty
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Smarty

1,675
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,675
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
33
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Smarty
  • 2. What is Smarty?Smarty is a web template system written in PHP Although Smarty is known as a "Template Engine" ,The Goal of Smarty?One of Smartys primary design goals is to facilitate the separation of application code frompresentation.*) Designers cant break application code. They can mess with the templates all they want, but thecode stays intact. The code will be tighter, more secure and easier to maintain.*) Programmers arent messing with templates. They can go about maintaining the application code,changing the way content is acquired, making new business rules, etc. without disturbing thepresentation layer.
  • 3. Features of Smarty1) Caching2) Debugging3) Compiling4) Plugins,....Is Smarty right for me?Smarty is not a simple tag-replacing template engine.Although it can be used for such a simple purpose, itsfocus is on quick and painless development anddeployment of your application
  • 4. Layer Of Website: Presentation Logic Layer Business Logic Layer Data Access Layer %%2B^2PHP Code HTML Code B9^2B99 (*.tpl) Smarty Engine D626%% *.tpl.php
  • 5. Installing and Configuring Smartyhttp://www.smarty.net/download.php (*.tar.gz) - Smarty 2.6.26➔• smarty.class.php➔• smarty_Compiler.class.php➔• config_File.class.php➔• debug.tpl➔• internals➔• plug-ins <?php require(Smarty.class.php); $smarty = new Smarty; ?> Built-in Smarty Variables➔$smarty->template_dir = Theme Directory;➔$smarty->compile_dir = Compile Directory;➔$smarty->cache_dir = _Cache Directory;➔$smarty->config_dir = Config Directory;➔$smarty->caching = false;➔$smarty->debug_tpl = debug.tpl;➔$smarty->debugging_ctrl = URL;
  • 6. Array is Key of SmartyOne Dimension Array:$my_array = array (Element 1, Element 2, Element 3, Element 4, Element 5);$fruit = array(apple, banana, blackberry);Two Dimension Array:$shop = array( array( Title => "rose", Price => 1.25, Number => 15 ), array( Title => "daisy", Price => 0.75, Number => 25, ), array( Title => "orchid", Price => 1.15, Number => 7 ) );
  • 7. Array is Key of Smarty
  • 8. index.php<?php$var = 100;$smarty->assign(var,$var);$smarty->display(index.tpl);?>index.tpl<html...{$var}.../html>$smarty->assign(arrayvar => $var,var2 => $var2,);
  • 9. index.php<?php$var = array (1,2,3,4);$smarty->assign(var,$var);$smarty->display(index.tpl);?>index.tpl<html...{$var[1]}{section name=customer loop=$var step=1}{$var[customer]} , {$smarty.section.var.index}{/section}.../html>
  • 10. Logical ConditionsQualifier Alternatives Syntax Example Meaning PHP Equivalent == eq $a eq $b equals == != ne, neq $a neq $b not equals != > gt $a gt $b greater than > < lt $a lt $b less than <
  • 11. Available Modifiers {$somevalue|capitalize} {$somevalue|count_characters} {$sometext|indent:10:"#"} {$sometext|nl2br}{$somevalue|replace:"mice":"dogs"} {$sometext|strip_tags} {$sometext|wordwrap:60|nl2br}
  • 12. Tips{include file="footer.tpl"}{literal}{script}{/script}{/literal}$smarty->debugging = TRUE;$smarty->debugging_ctrl = urlhttp://127.0.0.1/index.php?SMARTY_DEBUGWEB DIRECTORY:/pulic_html/template
  • 13. http://www.smarty.net END

×