Using the bake command, cakephp will read all your source files and it will extract all the text to translate. So it’s very important that you write the string in the i18n function and don’t pass just variables. For example to extract the text, using the command line go to you app directory, and execute … Continue reading CakePHP: generate .po localization files using Shell
Category: CakePHP
In many cases when we want to formulate complex queries, that need joins between tables, we can still add joins on the fly by adding it to the call of find $students_of_grade = $this->User->find('list',array( 'fields'=>array('UserData.user_id'), 'joins'=>array( array( … Continue reading CakePHP joining tables
By default a CakePHP controller uses a model with singularized name, for example a controller with name Students will use by default a model named Student, But if you want or have to change the default model for a controller you can set it using $modelClass member attribute for example for a controller named ClassesController … Continue reading CakePHP: change default model for a controller
In CakePHP it is pretty easy to change the way that users reach to a specific action to another beautiful URL for ex: you may have a page that contains category details, and users reach to it via: http://domain.com/categories/view/id controller is "categories", action is "view", and it takes 1 parameter id and you may want … Continue reading CakePHP: Custom routes and pagination
in CakePHP 1.x Through the RequestHandler Component: RequestHandlerComponent::getClientIp(); in CakePHP 2.x RequestHandler::getClientIp() is deprecated, so you can use the CakeRequest object $this->request->clientIp(); of course you can still use the server variable $_SERVER['REMOTE_ADDR']
By default, the maximum number of fetched rows on pagination is set to 100 rows, whatever number of rows higher than it you assign it to the "limit", property, it will not affect, but you can adjust it as part of the pagination options: public $paginate = array( // other keys here. 'maxLimit' => 10 ); … Continue reading CakePHP max number of fetched row on pagination
I observed that CakePHP treats tinyint fields as boolean (true/false) , but after investigation found that: if you set the data type for a field to tinyint with length of 1, then CakePHP will treat it as boolean. So I changed it to tinyint(2), That's weird about CakePHP
Here is a simple tutorial on how to develop a multilingual cakephp application through URLs, After having as desired number of language translation files in /app/Locale we want to direct the application to direct the application to use each language through URL prefix like http://www.application.com/eng/pages/about/ and http://www.application.com/ara/articles/view/123 1- First add this route to the default … Continue reading CakePHP: Multilingual application using URL routes
To use the cache helper in any view or controller, you must first uncomment and set Configure::Cache.check to true in core.php of your app/config folder. If this is not set to true, then the cache will not be checked or created. Configure::write('Cache.check', true);
use the useful callback disableCache(), that will tell the user’s browser not to cache the results of the current request. This is different than view caching. The headers sent to this effect are: Expires: Mon, 26 Jul 1997 05:00:00 GMT Last-Modified: [current datetime] GMT Cache-Control: no-store, no-cache, must-revalidate Cache-Control: post-check=0, pre-check=0 Pragma: no-cache