简体   繁体   English

蛋糕PHP中的模板和视图之间的区别

[英]Difference between template and view in cake php

I am new to CakePHP 3.0. 我是CakePHP 3.0的新手。 Previously I used CodeIgniter. 以前我使用CodeIgniter。 In CakePHP 3.0 we have to create our HTML designs in src/Template rather than src/View . 在CakePHP 3.0中,我们必须在src/Template而不是src/View创建HTML设计。

My question is what is the difference between a View and Template? 我的问题是视图和模板之间有什么区别?

Since 3.0 the folders containing view files now go under src/Template instead of src/View. 从3.0开始,包含视图文件的文件夹现在位于src / Template下,而不是src / View下。 This was done to separate the view files from files containing php classes (eg. Helpers, View classes). 这样做是为了将视图文件与包含php类(例如,Helpers,View类)的文件分开。

so basicly your html (.ctp files) go into src/Template and your .php files 'helping' your templates go into src/View 因此,基本上,您的html(.ctp文件)进入src / Template,而您的.php文件“帮助”您的模板进入src / View

Cakephp uses the ctp extension. Cakephp使用ctp扩展名。 Stands for cake template. 代表蛋糕模板。 And for CRUD it uses add, view, edit, index ctp files. 对于CRUD,它使用添加,查看,编辑,索引ctp文件。

In cakephp 2.0 the ctp (template files) are stored in app > View > ... folder. 在cakephp 2.0中,ctp(模板文件)存储在app> View> ...文件夹中。

In cakephp 3.0 the ctp files are stored in src > Template > ... or src > View > ... folder. 在cakephp 3.0中,ctp文件存储在src>模板> ...或src>视图> ...文件夹中。

View: Presentational classes are placed here: cells, helpers, and template files. 视图:演示类位于此处:单元格,助手和模板文件。

Template: Presentational files are placed here: elements, error pages, layouts, and view template files. 模板:演示文件位于此处:元素,错误页面,布局和视图模板文件。

对于src / Template,它是查看文件的文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM