CakePHP: generate .po localization files using Shell


  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

CakePHP joining tables


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

CakePHP: change default model for a controller


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

Parsing XML easily in CakePHP 2


It is very easy to parse XML in CakePHP , here is an example in CakePHP v2 // import XML Utility class App::uses('Xml', 'Utility'); // your XML file's location $xml1 = Xml::build('http://url-of-XML'); $xml2 = Xml::build('http://http://url-of-XML', array('return' => 'simplexml')); // $xml now is a instance of SimpleXMLElement // New method using DOMDocument $xml3 = Xml::build('http://url-of-XML', array('return' … Continue reading Parsing XML easily in CakePHP 2

CakePHP 2 aggressive Security – continued


CakePHP 2.0 has another aggressive security which is shown clearly when trying to make an ajax request to an action via method POST, it fires security error that says "Request is blackholed due to auth". The Solution to disable this aggressive validation for this action to set security attribute $validatePost to false.   property SecurityComponent::$validatePost Set … Continue reading CakePHP 2 aggressive Security – continued