Aug 3, 2014 | CakePHP |
Basically, on your CakeEmail object:
$CakeEmail = new CakeEmail();
$CakeEmail->addHeaders(array('X-Mailer' => 'My custom X-Mailer'));
If set manually Cake will not add his default value ‘CakePHP Email’.
Source:
http://stackoverflow.com/a/18032036
Jan 28, 2014 | CakePHP |
The default hash type of Cakephp 2.0 is sha1. But when you have set a Security.Salt in the core.php this will be added before your password and before the encryption is done.
To generate a password with Salt you can either create an User::add method in Cakephp and use the Authcomponent or create some your own. I needed it for fast checking user accounts with a javascript frontend (no views are used).
// Your salt from core.php
// Configure::write('Security.salt', 'e4ac429040b9d4552bc425b677b64aca104c5f84f');
$salt = 'e4ac429040b9d4552bc425b677b64aca104c5f84f';
$yourpassword = 'mysecret';
$password = sha1($salt.$yourpassword);
// The password to use in Cakephp with the Authcomponent
print $password;
Thats all, you use that password in your mysql admin tool to create users on the fly.
Source
Feb 3, 2013 | CakePHP |

CakePHP: Merge Add and Edit actions into a single HTML form
This CakePHP example will show you how to merge your Add and Edit forms into a Single Form action.
This may be of benefit if you have a form with complex controller logic that you don’t want to duplicate.
(more…)
Feb 3, 2013 | CakePHP |

Incrementing a field in CakePHP like Hits & Votes
Let’s say you have an application, where users can place votes for their favorite products and you’d like to increment the current number of votes by one or count number of hits(Number of page views)
It’s very easy by using updateAll:
$this->Product->updateAll(array('Product.vote'=>'Product.vote+1'), array('Product.id'=>40));
You may want to restrict Product model by using unbindModel, containable, etc.
Also, you don’t have to pass in the second argument to updateAll, if you wish to update all records in your table.
Dec 17, 2012 | CakePHP |

How to retrieve data from another model into view templates or anyplace
To retrieve data from another model into view templates or anyplace
$this->Model2 = ClassRegistry::init('Model2 ');
$this->Model2 ->find();
Or if the models are associated, just daisy chain the finds:
$results = $this->Model1->Model2->find();
Nov 4, 2012 | CakePHP |

CakePHP: How to add global variables
How to define a global variable in CakePHP which i can use anywhere in the application.
Solution:
You can write a new config value or you can define a variable or constant in bootstrap.php.
I have done it this way
Declaring Global Variable: Configure::write(‘var_name’,’var_value’);
Reading Global Variable: Configure::read(‘var_name’);
Jun 15, 2012 | CakePHP |

CakePHP – jQuery Autocomplete Tutorial
In this tutorial, i will show you how to implement jQuery UI’s autocomplete widget in cakephp. The script in this tutorial is copy paste from tutorialzine article “A Simple Movie Search App w/ jQuery UI” . We are using a MySql database containing a users table. When you start typing a user name in the text box of the search form, an AJAX request is sent to controller. The controller returns a JSON object with suitable user name.
This is what we’re going to create:

CakePHP – jQuery Autocomplete Tutorial
(more…)
Feb 27, 2012 | CakePHP |

CakePHP: Configuring Apache
There is some tweaking that we need to perform in order to make sure that Apache runs CakePHP applications smoothly. Many Apache installations may not require the following tweaking, as they might be set as default, but it is always a good idea to check if the following settings are present.
(more…)
Feb 19, 2012 | CakePHP |

CakePHP: Understanding the MVC Pattern
The MVC (Model View Controller) pattern is a commonly used design pattern in software development, where the code is separated into three major parts: models, views, and controllers. The exact purpose of each part depends on the implementation, as it may vary from one framework to another. Here, we are going to describe the way CakePHP implements the MVC pattern. So, this is not a general discussion on MVC pattern, rather we are only going to see Cake’s own MVC implementation. As we have already mentioned, CakePHP separates the code into three separate parts: models, views, and controllers.
(more…)
Feb 17, 2012 | CakePHP |

What is CakePHP?
What is CakePHP?
According to the official CakePHP website (http://cakephp.org):
“Cake is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.”
Someone who is new to frameworks might not understand parts of the definition. But understanding a few key terms will make the job much easier.
(more…)
Recent Comments