Set the attribute $ view to 'smarty 'in the controller, and indicate to the controller that I use Smarty as The View layer, instead of using the built-in cake
I tried two methods:
One is: http://projects.simpleteq.com/CakePHP/smarty.html
Another is: http://cakeforge.org/snippet/detail.php? Type = snippet & id = 6
How to say http://cakeforge.org/snippet/detail.php? Type = snippet & id = 6 is also the official implementation, and it fails to survive for half a day.
No way to use the first one.
1. download http://projects.simpleteq.com/cakephp/smarty.zip, decompress and place it in the app/viewsdirectory.
2. Download (http://smarty.php.net/do_download.php? Download_file1_smarty-2.6.18.tar.gz) and install Smarty in the/vendors/smarty directory.
3. set the attribute $ view to 'smarty 'in the controller to indicate to the controller that I use Smarty as The View layer instead of using the built-in View of cake.
Public $ view = 'smarty ';
4. the Template location is the same as that of the ctp template. The Knowledge extension is. tpl.
5. set template variables in the controller
$ This-> set ('Var ', $ var );
6. output variables in the template
{$ Var}
Exmaple:
Class SomeObjectsController extends AppController
{
Var $ name = "SomeObjectsr ";
Var $ helpers = array ("Html", "Text ");
Function index_s ()
{
$ This-> view = "Smarty ";
$ This-> set ("SomeValue", "Called using smarty's renderer .");
Return;
}
Function index ()
{
$ This-> set ("SomeValue", "Called using the CakePHP's built-in renderer .");
Return;
}
}
Template File
Head 1
{$ Html-> link ('This is a connection', 'http: // blog.csdn.net/httpnet ')}
{$ SomeValue}