Trying to bake my controllers from a custom template.
As per the cookbook, I've baked a new plugin, and created the following directories:
plugins/MyTemplate/src/Template
plugins/MyTemplate/src/Template/Bake
plugins/MyTemplate/src/Template/Bake/Controller
plugins/MyTemplate/src/Template/Bake/View
In Bake/View I've created the basic CRUD templates, and they're baking fine. In Bake/Controller I've created a controller.twig file. It appears to be ignored. What am I missing?
I already have model file, but that model doesn't have any test or test fixtures currently. Is there a command in cake console, that would generate test and test fixtures based on already created model. I'm using cakePhP 2.9.
Thank you!
I was able to create following files wit following commands.
cake bake test model "modelName"
cake bake fixture "modelName"
I am using a couple of plugins in a CakePHP application that come with predefined translations in their Locale directories.
However, despite I have set the language setting, messages from these plugins are not being translated.
First question: can CakePHP retrieve those plugin translations by default or do I have to create my own translation files every time I use a plugin in a different application?
If CakePHP should retrieve the translations in plugin's Locale directory, is there something else I have to do besides setting Configure::write('Config.language', 'spa')?
Thank you!!
UPDATE: I am using CakePHP 2.1
I have a plugin with user model, profile model and an user controller, in this user model is associated with profile model. In my main model folder (under app), I have user model and user controller(here I have not associated with profile). Sometimes I'm getting errors saying that user model is not associated with profile model. Also sometimes I'm getting the error - "missing action logout in users controller". I have given the logout action in the app/controller/userscontroller but that method is not available in myplugin/usercontroller. Im using cakephp2.0.. How can I solve this issue ? How cakephp is setting the cache for models and controllers ? I don't want to completely disable the cache.
I've had trouble with this as well. Basically it comes down to the fact that Cake doesn't support controllers with the same class name. So a controller named UsersController on plugin and app level will cause trouble with caching and some components (the Auth component, for example).
Support for identical classnames in various levels of a Cake application will come in Cake 3.0 which will require PHP 5.3, which in turn supports namespaces, a feature needed for correctly handling duplicate class names.
With no word on when Cake 3.0 will be released as the 2.0 branch is just out of beta, I refactored my plugin by prepending the plugin name to my controllers, views and models.
So UserModel became PluginUserModel and UsersController became PluginUsersController. It's a bit of a hassle, because you have to update all the views and variables which use the model's name.
My original question contains some links to the Cake bug tracker where similar questions were raised, should you be interested in some background,
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.
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
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.
See more in http://www.fileinfo.com/extension/ctp
You can change the .ctp file extention by using property in Controller or AppController:
public $ext = '.php';
.ctp is the view file extention of CakePHP template file.
It stands for "CakePHP Template".
CakePHP provides an extendable architecture for designing, developing and distributing software using a rapid development framework. The .CTP file extension supports CakePHP's view scripts and provides the set of helpers appropriate for CakePHP version 1.2.
CTP files are templates for the CakePHP framework for application development, managed by the Cake Software Foundation. CTP files contain information for the program's user interface and dictates how an application appears to the user.... More »
http://book.cakephp.org/2.0/en/views.html#view-templates
Cakephp follow 3-tier architecture, Model ,Controller and View are 3-tier of this architecture.All MVC Framework follows this architecture Including Cakephp, .ctp extension used by Cakephp views.
S.jpg
ctp stands for CakePHP Template
It is a template file used by CakePHP. Basically it is a application View layer, it contains the PHP,Html "view" code to display the end user.
Cakephp is based on MVC framework. 'M' stands for model, 'C' for Controller and 'V' for Views. Model is used for interacting with database tables, Controller used for controlling request and response of client and also for logic implementation and process and views are for presentation. Other two have file extension .php, but views has .ctp extension. Reason is that Cakephp architecture is using template caching internally, such as tpl in Smarty.
CTP files may contain layouts, elements, or helpers. Layouts define presentation code. Elements contain smaller, reusable segments of view code. Helpers contain classes that encapsulate logic used between many views, elements, or layouts.
CTP files are stored in the CakePHP /app/views directory.
the ctp file type in cakePHP is used for views it can be used to represent :
1. The standard views, wich are related to a model and a controller;
2. Elements, wich can be inserted in other views (Pages, or standard view);
3. Pages : Static pages .
Inside a view you can use HTML and PHP, and in the most of cases you have an object available, wich represent the model (Example $Product).
CakePHP's View Class has a class varibale called $viewExtension or perhaps $viewExt and its default value is set to 'ctp' which stands for cake php template, you can over write this value in any of your controller or in derived view classes or in any controller action within the scope of code.
.ctp files are CakePHP Template Pages, that is view templates.
It is used for the view in the MVC that shows output in the browser and act as a view for a controller action.
JSON, XML, HTML, JS, CSS, PHP code can be written in it.
More than as HTML/PHP pages, it shows data sent from controller.
Also .ctp files CakePHP can act as a layout that wraps the view around it.
Its a view file from where controller render the presentation login.You can change the extension ".ctp" to ".php" for views to set the $ext property for specific controller $this->ext = '.php'