Now I don’t need javascript to do a ton of heavy lifting here. 'url' => array('controller' => 'hoodies', 'action' => 'submit'), Let’s say I create the following form with cakePHP: echo $this->Form->create('Hoody', array( Why gather specific form fields to submit with your ajax call, when you can simply serialize all the form data (as long as it was created with CakePHP’s htmlFormHelper). Simply remove the cache folder completely, create a new “cache” folder with “persistent”, “models” and “views” as subfolders. If you look at your default cake install under the tmp/cache directory you’ll see there are three folders “persistent”, “models” and “views”. Mostly permission based stuff saying file engine couldnt write to the file “access denied.” Well no worries. Now everything is peachy except for about a million errors on your normally 100% functioning cake app. You removed your ignored files with: git rm -r /absolute/path/to/directory You uploaded some tracked files, pulled with your other workstation and then realized your mistake. You forgot to add the “tmp” directory to. This will force ajax headers to stop with the keep-alive stuff… Hint #6: If you cake application sends keep alive headers or seems to be hanging…you can stop it manually: $this->response->send() The /htdocs/project/app/webroot/.htaccess: Īnd finally, the /htdocs/project/.htaccess: htaccess in your project root should have this: htaccess file in your project root directory. One in your “app” folder and finally another. If you download the zip from github for cakePHP, and it gives the error “URL rewriting is not configured properly” then it’s most likely the. $r = array('data' => 'stuff', 'more_data' => 'more stuff') Then send the response: $this->response->type('json') Make an array of data, encode it in json with PHP and set the response body to the encoded array. You can respond to ajax calls with json easily in cakePHP, no need to set autorender to false for this one. This allows that model to use another database connection defined in your “database.php” file. There’s a special variable you can use for this: public $useDbConfig = 'another_database_name' Well, in order for me to check some information about the users, my “Bouncer” needs access to call the other database… Let’s also say I’m a giant retard (true) and I put all the users on the list in a different database. He only allows people in who are on the list. Let’s say I make something called a “BouncerModel” which is supposed to act like a bouncer at a nightclub. I can also use cake’s “loadModel” function in my controller like this: $this->loadModel('Login') Then I can call $this->Login->find() or whatever… Cake will associate my controller with the LoginModel class. So I can say in my controller: var $uses = array(Login') But let’s say I have “LoginController”…well I don’t want to rename it to “LoginsController” just to keep with tradition. Well cake is smart enough to figure that out. For instance if you have a controller named “UsersController” in the file “UsersController.php” and then have a model named “UserModel” in a file named “UserModel.php” in the models folder. Cake will automatically associate your controller with the correctly named model. Normally, if you use a default setup you don’t need this. In your controller you find a variable called “$uses”. As a result, here’s what to remember if you’re just getting started with cakephp (again…). I’ve been getting back into cakephp and I’ve forgotten so much shit that I’m finding it useful to log all of this stuff. Hey all, as usual I don’t have a whole lot of time to explain myself or go into detail.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |