Skip to main content


Showing posts from October, 2015

Internationalizing in Cakephp

Steps how to implement multiple language in Cake PHP  Step 1: Set the route configuration in app/Config/routes.php               // i.e like               Router::connect('/:language/:controller/:action/*',array(),array('language' => '[a-z]{3}'));  Step 2: Set the config language in app/Config/core.php             Configure::write('Config.language', 'eng');   Step 3: create Helper in app/View/Helper/NewHtmlHelper.php             App::uses('HtmlHelper', 'View/Helper');            class NewHtmlHelper extends HtmlHelper {                   public function url($url = null, $full = false) {                   if(!isset($url['language']) && isset($this->params['language'])) {                        $url['language'] = $this->params['language'];                   }                   return parent::url($url, $full);            }    Step 4: N

Generate XML file in Cakephp

Steps to Generate XML file using CakePHP: Step-1 Enable to parse xml extension in config route.php file.     Router::parseExtensions('xml'); Step-2 Add Request Handler Component to the Controller    var $components = array(‘RequestHandler’); Step-3 Add controller Action For XML Generation in Post Controller     function generateXMLFile()     {         if ($this->RequestHandler->isXml()) { // check request type             $this->layout = 'empty'; // create an empty layout in app/views/layouts/empty.ctp              }        }  Add header code in empty layout <?php header('Content-type: text/xml');?> <?php echo $this->Xml->header(); ?> <?php echo $content_for_layout; ?> Step-4 Set up View To generate XML Create xml folder inside Posts view and file name is generateXMLFile.ctp "view/Posts/xml/generateXMLFile.ctp " <response>        <posts>               <Post>                      <id>