Cakephp: integration with Smarty

Source: Internet
Author: User
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}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.