Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a .ctp file used for in CakePHP?

I'm starting to use CakePHP, and I'm in the process of reading the manual. About halfway down the page, there's this comment:

// Render the element in /views/elements/ajaxreturn.ctp 

So a very simple question: what's the .ctp extension refer to? What's the general use case?

Thanks.

like image 624
Dirk Avatar asked Aug 26 '09 01:08

Dirk


People also ask

What is a CTP file?

Template file used by CakePHP, a development framework for PHP Web applications; contains the PHP "view" code within the Model-View-Controller (MVC) software architecture design pattern; stores a template for how information is displayed in the Web application.

How do I create a view in CakePHP?

php file at src/Controller/ProductsController. Copy the following code in the controller file. Create a directory Products at src/Template and under that folder create a View file called view. php. Copy the following code in that file.


1 Answers

CakePHP 1.2 introduced .ctp as its file extension for views.

CakePHP view files are written in plain PHP and have a default extension of .ctp (CakePHP Template). These files contain all the presentational logic needed to get the data it received from the controller in a format that is ready for the audience you’re serving to.

http://book.cakephp.org/2.0/en/views.html#view-templates

like image 178
Sampson Avatar answered Oct 06 '22 07:10

Sampson