cakephp

Cakephp 404 not found (The requested URL .... .xsd was not found on this server)

This happened when i had a controller called Types and a file in my webroot called types.xsd. When i turned off Multiview in my site configuration file it started working.
<Directory ....>
 
Options Indexes FollowSymLinks MultiView
 
</Directory>
I just removed the MultView option for now.

ExtJS ext.data.jsonwriter and cakephp

Just spent quite abit of time getting an EditorGrid properly creating and updating rows automagically using Ext Writer. Except it wasn't so magical.
Notes:
- Create requires success: true and then the created record (including the id).
Use this snippet:
echo '{"success":'.$success.', results:'.$javascript->Object($record).'}';
in the above results should be whatever your roots property is in your store reader config. For example:
                reader: new Ext.data.JsonReader({
                        totalProperty: 'total',
                        successProperty: 'success',
                        root: 'results',
                        idProperty: 'id', etc
Example of working create json string:
{"success":true, results:{"id":"47","jobId":"47","jobType":"7",
"partName":"0101012","partDescription":"3.0 Metre Crossover Network Cable",
"quantity":"1","price":"3.5"}}
Example of working update json string:
{success:true, id:11}
After an update you can use $this->MODELNAME->id to get the id for the json.
Destroy just needs
{success:true}
Read example (all records for grid):
{"total":2, "results":[{"id":"46","jobId":"47","jobType":"7",
"partName":"0101104","partDescription":"Dual Back Box","quantity":"1","price":"4.26"},{"id":"47","jobId":"47","jobType":"7",
"partName":"0101012","partDescription":"3.0 Metre Crossover Network Cable","quantity":"1","price":"3.5"}]}

Cakephp Object not found!

 If you are getting an Object not found! cakephp error check out your httpd.conf

<Directory />

Options FollowSymLinks

AllowOverride All

# Order deny,allow

# Deny from all

Cakephp Session object destruction failed / session_regenerate_id() annoyance

While writing a webapp I suddenly started getting this error:

Session object destruction failed

Apparently it is related to session_regenerate_id(). For now I have solved it by setting security.level to medium in core.php.

On my todo list for a proper fix before release.

Print Arrays nicely using pr

I recently had to do some debugging of arrays. Print_r() is very, very ugly:
Array ( [0] => struct SidAndAttributesType { string SecurityIdentifier; unsignedInt Attributes; } [1] => struct NonEmptyArrayOfGroupIdentifiersType { SidAndAttributesType GroupIdentifier; } [2] => struct
I did some research and found a nice solution: use pr() instead of print_r.
Array
(
    [0] => struct SidAndAttributesType {
 string SecurityIdentifier;
 unsignedInt Attributes;
}
    [1] => struct NonEmptyArrayOfGroupIdentifiersType {
 SidAndAttributesType GroupIdentifier;
}
    [2] => struct NonEmptyArrayOfRestrictedGroupIdentifiersType {
 SidAndAttributesType RestrictedGroupIdentifier;
}
Shorter, simpler, sweeter!

Cakephp set page title

To set the page title in cakephp, put this in your controller method:
$this->set('title', 'My Page Title');

Cakephp home.ctp/index controller and a controller without a model

1) Create a new controller (the one below has no model)
class DashboardsController extends AppController {
	var $name = 'Dashboards';
	var $uses = array();
		function index() {
 
	}
}
2) Reroute in routes.php in the app folder.
 
Router::connect('/', array('controller' => 'dashboards', 'action' => 'index'));

Just wasted 20 minutes looking for whitespace...

I just wasted 20 minutes going through files looking for a white space that was causing "headers already sent" error message on login. I finally found it BEFORE the <? (i was looking at the ?> end).

Grrr....

Syndicate content