Development

Changeset 14326

You must first sign up to be able to contribute.

Changeset 14326

Show
Ignore:
Timestamp:
12/26/08 01:12:40 (4 years ago)
Author:
insaini
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfSmartyPlugin/trunk/README

    r14317 r14326  
    1 = sfSmarty plugin = 
     1sfSmarty plugin 
     2=============== 
    23 
    3 == Overview == 
     4## Overview ## 
    45 
    56This plugin gives you the ability to use the Smarty templating engine for your view templates. 
    67http://www.smarty.net 
    78 
    8 == Installation == 
     9## Installation ## 
    910 
    10 To install sfSmartyPlugin: 
     11#### sfSmartyPlugin #### 
    1112 
    12 Checkout the plugin from the SVN repository http://svn.symfony-project.com/plugins/sfSmartyPlugin/trunk 
     13Checkout the plugin from the SVN repository http://svn.symfony-project.com/plugins/sfSmartyPlugin/trunk, download and install the pear package or via symfony plugin install. 
    1314 
    14 Its currently the best working copy. 
    15  
    16  
     15#### Smarty #### 
    1716You must also install Smarty (http://www.smarty.net) 
    1817 
     
    2322It can be checked out from the Smarty SVN repository here, http://smarty-php.googlecode.com/svn/tags/Smarty_2_6_22/ 
    2423 
     24## Configuration ## 
     25Once you have installed smarty, you must edit the app.yml in each of your applications that you intend to use the smarty engine. 
    2526 
    26 Once you have installed smarty, you must edit the app.yml in each of your applications that you intend to use the smarty engine. 
    27 {{{ 
    28 # default values 
    29 all: 
    30   sfSmarty: 
    31     class_path: lib/vendor/smarty/libs 
    32     template_extension: .tpl 
    33     template_security: false 
    34 }}} 
     27  # default values 
     28  all: 
     29    sfSmarty: 
     30      class_path: lib/vendor/smarty/libs 
     31      template_extension: .tpl 
     32      template_security: false 
     33 
    3534The Smarty.class.php file is located under your smarty/libs folder. Thus the /libs on the end of the class_path. 
    36  
    3735 
    3836Clear the cache to enable the autoloading to find the new classes: 
    3937 
    40  
    41 == Versions ==  
     38## Versions ##  
    4239 
    4340This plugin is intended for Symfony 1.1 or 1.2 Only. 
    4441 
    45  
    46 == Usage == 
     42## Usage ## 
    4743 
    4844Smarty is considered one of the best templating engines for PHP.   
     
    5046 
    5147If you intend to use Smarty as the default templating engine, edit your project root/config/module.yml file. (if it doesnt exist, create one) 
    52 {{{ 
    53 default: 
    54   view_class: sfSmarty 
    55   partial_view_class: sfSmarty 
    56 }}} 
     48 
     49 default: 
     50   view_class: sfSmarty 
     51   partial_view_class: sfSmarty 
     52 
    5753From then on all template files ending with .tpl (or whatever extension you set during installation) will be processed with sfSmarty. 
    5854 
     
    6157You can still utilize .php templates as the plugin will now check the extention of the template and use the appropriate renderer. 
    6258 
     59sfSmartyPlugin also contains a settings.yml in its config folder. Suggest leaving this alone. 
    6360 
    64 sfSmartyPlugin also contains a settings.yml in its config folder. Suggest leaving this alone. 
    65   
     61### Templates ###  
     62When using Smarty as the default templating engine, you must also rename the default symfony layout.php file to layout.tpl 
     63and then update it so it looks like this: 
    6664 
    67 == Example Usage == 
     65  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     66  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
     67  <head> 
     68   
     69  {include_http_metas} 
     70  {include_metas} 
     71   
     72  {include_title} 
     73   
     74  <link rel="shortcut icon" href="/favicon.ico" /> 
     75   
     76  </head> 
     77  <body> 
     78   
     79  {$sf_content} 
     80   
     81  </body> 
     82  </html> 
     83 
     84Nice and Clean isnt it. =D 
     85 
     86### link_to_app ### 
     87 
     88The link_to_app helper method will allow easy linking between applications 
     89 
     90  {link_to_app app='admin' name='Admin App Link'}  
     91 
     92With Optionals 
     93 
     94  {link_to_app app='admin' name='Admin App Link' internal_uri='default/index' path='/admin/ subdomain=false} 
     95 
     96From above the subdomain and path arguments will generally be used together. If you do not have your applications on separate subdomains then you would set subdomain to false and your path would have the web folder location of your application index scripts. The path argument MUST have a trailing AND leading slash. 
     97 
     98## Example Usage ## 
    6899 
    69100sfSmarty will automatically attach sf_data, sf_context, sf_request, etc.. to the smarty vars. 
    70101 
    71102These can be used as such: 
    72 {{{ 
     103 
    73104  {$sf_data->get('arg')} 
    74 }}} 
     105 
    75106 
    76107Any variable in an action that is assigned to $this is also available, for example in the action: 
    77 {{{ 
     108 
    78109  $this->var = 'foobar'; 
    79 }}} 
     110 
    80111Can be used in the template as:  
    81 {{{ 
     112 
    82113  {$var} 
    83 }}} 
    84  
    85 This is typical Smarty. All values are currently assigned (and thus copied), this will be updated as soon as possible to assign_by_ref (assigned by reference). 
    86  
    87 The smarty vars (sf_data, sf_context, ..) are currently assigned by references. 
    88114 
    89115 
     116This is typical Smarty. All values are assigned by reference to Smarty. 
     117The smarty vars (sf_data, sf_context, ..) are also assigned by references. 
     118 
     119### Smarty Methods ### 
    90120Smarty internal functions for looping and conditions work as is and should be used. 
    91 {{{ 
     121 
    92122  {foreach from=$arr item='item'} 
    93123    My item is {$item} 
    94124  {/foreach} 
    95 }}} 
     125 
    96126Refer to the Smarty documentation.  
    97127 
     128The Javascript helper tag is also available and must be used as such: 
    98129 
    99 The Javascript helper tag is also available and must be used as such: 
    100 {{{ 
    101130  {javascript} 
    102131    function someFunc() {ldelim} 
     
    104133    {rdelim} 
    105134  {/javascript} 
    106 }}} 
     135 
    107136Because the braces have a specific use in Smarty. It is suggested (of course) that the bulk of your javascript should be in javascript files which are attached when needed. Keep template javascript to a minimum. 
    108137 
     138To attach helpers: 
    109139 
    110 To attach helpers: 
    111 {{{ 
    112140  {use helper='Javascript'} 
    113 }}} 
     141 
    114142The {use} tag does not accept an array of values currently. 
    115143 
     144Smarty can also be utilized within actions via static calls. In an action: 
    116145 
    117 Smarty can also be utilized within actions via static calls. In an action: 
    118 {{{ 
    119146  $smarty = sfSmarty::getInstance()->getSmarty(); 
    120147  $smarty->register_object('foobar',$myobj); 
    121 }}} 
     148 
    122149$foobar will then be available as an object reference in your template. 
    123150 
    124  
    125 == Final Notes == 
     151## Final Notes ## 
    126152 
    127153I have tried to optimize certain methods and have cleaned up some from the last 0.12 release. 
     
    131157It may even be possible to store the references to these compiled templates to have the sfPHPView load them directly which reduce template rendering time a little further. 
    132158 
    133  
    134159Symfony view caching can be used together with sfSmarty but it is not suggested to combine Symfony view cacheing with Smarty view caching as it is just extra overhead. Both cached files would be essentially the same.  
  • plugins/sfSmartyPlugin/trunk/package.xml

    r14319 r14326  
    1414 <time>06:34:35</time> 
    1515 <version> 
    16   <release>0.2.2</release> 
     16  <release>0.2.3</release> 
    1717  <api>1.0.0</api> 
    1818 </version> 
     
    6868      <release> 
    6969        <version> 
    70           <release>0.2.2</release> 
     70          <release>0.2.3</release> 
    7171          <api>1.0.0</api> 
    7272        </version> 
     
    8181        <license>MIT</license> 
    8282        <notes> 
    83            * insaini: Updated README, fixed caching with old partial view class, optimized renderFile and load helpers methods, and allowed rendering of .php via parent class automatically. 
     83           * insaini: - Updated link_to_app helper method for correct behaviour between environments 
     84- Updated sfSmarty to assign_by_ref all values from the view 
     85- Updated sfSmarty to correctly select the renderer for the layout. 
    8486        </notes> 
    8587      </release>