PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

#! | 82 lines | 64 code | 18 blank | 0 comment | 0 complexity | 411478aa2fdb2f255d8801f0feb417f8 MD5 | raw file
 1= Known incompatibilities with Smarty 2 =
 3== Syntax ==
 5Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported but
 6deprecated. See the README that comes with Smarty 3 for more information.
 8== PHP Version ==
 9Smarty 3 is PHP 5 only. It will not work with PHP 4.
11== {php} Tag ==
12The {php} tag is disabled by default. The use of {php} tags is
13deprecated. It can be enabled with $smarty->allow_php_tag=true.
15But if you scatter PHP code which belongs together into several
16{php} tags it may not work any longer.
18== Delimiters and whitespace ==
19Delimiters surrounded by whitespace are no longer treated as Smarty tags.
20Therefore, { foo } will not compile as a tag, you must use {foo}. This change
21Makes Javascript/CSS easier to work with, eliminating the need for {literal}.
22This can be disabled by setting $smarty->auto_literal = false;
24== Unquoted Strings ==
25Smarty 2 was a bit more forgiving (and ambiguous) when it comes to unquoted strings 
26in parameters. Smarty3 is more restrictive. You can still pass strings without quotes 
27so long as they contain no special characters. (anything outside of A-Za-z0-9_) 
29For example filename strings must be quoted
30<source lang="smarty">
31{include file='path/foo.tpl'}
34== Extending the Smarty class ==
35Smarty 3 makes use of the __construct method for initialization. If you are extending 
36the Smarty class, its constructor is not called implicitly if the your child class defines 
37its own constructor. In order to run Smarty's constructor, a call to parent::__construct() 
38within your child constructor is required. 
40<source lang="php">
41class MySmarty extends Smarty {
42   function __construct() {
43       parent::__construct();
45       // your initialization code goes here
47   }
51== Autoloader ==
52Smarty 3 does register its own autoloader with spl_autoload_register. If your code has 
53an existing __autoload function then this function must be explicitly registered on 
54the __autoload stack. See 
55for further details.
57== Plugin Filenames ==
58Smarty 3 optionally supports the PHP spl_autoloader. The autoloader requires filenames 
59to be lower case. Because of this, Smarty plugin file names must also be lowercase. 
60In Smarty 2, mixed case file names did work.
62== Scope of Special Smarty Variables ==
63In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach... 
64had global scope. If you had loops with the same name in subtemplates you could accidentally 
65overwrite values of parent template.
67In Smarty 3 these special Smarty variable have only local scope in the template which 
68is defining the loop. If you need their value in a subtemplate you have to pass them 
69as parameter.
70<source lang="smarty">
71{include file='path/foo.tpl' index=$}
75Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset. 
76This is now used also on modifiers like escape as default charset. If your templates use 
77other charsets make sure that you define the constant accordingly. Otherwise you may not 
78get any output.
80== newline at {if} tags ==
81A \n was added to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source. 
82If one of the {if} tags is at the line end you will now get a newline in the HTML output.