开发者

How to integrate smarty in cakephp 1.2?

Can any1 suggest me some good and COMPLETE documentation开发者_如何学Go on integrating smarty templates in cakephp 1.2 and which version of smarty should I use with cakephp 1.2?


My advice... DONT. You should ask yourself why you want to. Is it worth all of the extra effort just so you can write PHP in the HTML files like {} instead of <?php ?> ?

I don't want to start a war about SMARTY vs PHP, but I would get away from SMARTY. It does not add value. There is nothing that smarty adds, it only rehashes the way you write the code.


CakePHP has a pretty good template engine that nearly all developers are more than happy with - so there isn't much out there for adding Smarty. There are two articles in the bakery which may be worth a read:

http://bakery.cakephp.org/articles/tclineks/2006/10/27/how-to-use-smarty-with-cake-smartyview

http://bakery.cakephp.org/articles/HyperCas/2008/06/11/the-cakephp-blog-tutorial-with-smarty

But I would urge you to check out:

http://book.cakephp.org/view/1078/Views

Which is a pretty handy guide on just what can be achieved with the CakePHP views.


I personally stick with normal PHP, but just wanted to point out that instead of blindly using Smarty, there are alternative template engines out there. Twig for example: is newer (PHP 5), looks nicer (think Django), can compile to PHP (faster) and is generally much better supported (for CakePHP).


This may be helps you...

http://bakery.cakephp.org/articles/icedcheese/2008/01/14/smarty-view-for-1-2

http://bakery.cakephp.org/articles/skler/2011/08/05/cakephp_2_0_0_beta_smarty_3


although I am a well-seasoned php developer, I would like to state one advantage to smarty - that I believe is valid: smarty takes it one step further to separate code from page design.

I believe the main intention of introducing templates into front-end systems is to separate the code/business logic from the the design.

This means that if you are merely a webpage designer, I'm sure you would much prefer to be working on an almost pure html page, free of coding logic interfering in the design layout.

this separation also helps to reduce the risk of a web designer interrupting the flow of business logic/code. I am fully aware that not all logic steps can be removed from templates (i.e. looping though objects in order to display lists for example), but introducing the template in the form of a SMARTY system for example can help to reduce that.

i hope that makes sense however I may about to personally negate all my above arguments by stating that I personally like the way cakephp uses its templates, and I personally intend to keep my developments working that way

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜