Category Archives: CakePHP

CakePHP captcha support for CakePHP 2.x and 3.x

Here is the latest CakePHP Captcha support for CakePHP Version upto 3.x.

Download for CakePHP 3.x
Download for CakePHP 2.x

NOTE:For best Image Captcha results this component requires GD and Freetype support enabled. Please check your phpinfo() to know whether your server supports this (See image below). Contact your hosting provider if any of these libraries is not enabled.

Continue reading

An example of CakePHP complex find conditions

Setting complex ‘find’ conditions in CakePHP can be tricky. I picked an example of Cakephp complex find conditions from one of my CakePHP projects.

I wanted to list all auctions which are “not closed” and whose’ end date/time is greater that the current date/time. I can use the following statement. Continue reading

How to get current theme name or theme working in cakephp

Making theme set and available by setting theme related properties in controller

Prior to cakephp 2.0

class UserController extends AppController {
    var $view = 'Theme'; //tells controller to use "ThemeView" class instead of the default "View" class
    var $theme = 'WhiteFeather'; //name of the theme folder which is supposed to be placed at views/themed/
}

Cakephp 2.0

class UserController extends AppController {
    public $viewClass = 'Theme'; //tells controller to use "ThemeView" class instead of the default "View" class
    public $theme = 'WhiteFeather'; //name of the theme folder which is supposed to be placed at View/Themed
}

Theme can be changed within a controller function or in beforeFilter/beforeRender by overriding the theme property:

$this->theme = 'BlackFeather';

You may want to know more about themes, here:
CakePHP 1.3 link http://book.cakephp.org/view/1093/Themes
Cakephp 2.0 documentation http://book.cakephp.org/2.0/en/views/themes.html