Tuesday, November 17, 2015

Call and use helper in controller Cakephp

Somebody said that there would have many ways to call Helper to use in view , but inspire I would show you how to implement it in Controller.php

class YourContrller extends Objects{
  pubic function yourfunction()
  {
  App::import('Helper', 'String'); 
  $string = new StringHelper(new View());
 
  $string->yourFunctionHelper();
 }
}


StringHelper.php

class StringHelper extends AppHelper{
  
   public function yourfunction()
   {
     .....
   }
} 

0 comments:

Post a Comment