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
Tag: CakePHP 2.0
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 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']
// import XML class App::uses('Xml', 'Utility'); // your XML file's location /*w is the code of the city, and u is the unit of temperature (c/f) $xml = Xml::build('http://weather.yahooapis.com/forecastrss?w=615702&u=c'); $xml should contain the following data, where you can extract whatever you want from it SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) … Continue reading Using Yahoo Weather API to get weather conditions in CakePHP2
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.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