Sameer Ahuja
  • Home
  • Blog
  • Playground
    • Visualize This
    • Read My RSS
    • Older
  • Contact
    • Calendar
  • Photography
  • Subscribe via RSS

CakePHP and AJAX: First pitstop

April 11th, 2007  |  Published in AJAX  |  1 Comment

I started out with the Cake framework for PHP some time back, and it’s been a mixed ride so far. Cake is a very powerful, but still somewhat incipient framework built on the MVC pattern of Ruby on Rails. Among it’s several cool features is inbuilt support for AJAX based applications.

A good starter tutorial in that direction lies here. And another one, a Flickr Gallery.

However, if you belong to the population of web developers who are not psychic or lucky, you would probably have something like this staring your face when you try the above tutorials -

Fatal error: Call to a member function on a non-object in C:\cake\app\views\layouts\default.thtml on line 8

That’s because both the tutorials do not explicitly mention that you need to declare the AJAX helper in the controller file if you are going to use AJAX features. The best way to do that is to copy the app_controller.php file from your cake/ directory, put it in your app/ directory and add the following piece of code to it:

var $helpers = array('Html', 'Ajax', 'Javascript');
This declares the Helpers in the parent class of all the controllers, so that you don’t need to re-declare them later. If you do that, though, make sure to have all the helpers declared again.

Responses

Feed Trackback Address
  1. Tengku Zahasman says:

    April 29th, 2007 at 9:53 pm (#)

    If someone could provide a good AJAX login tutorial with CakePHP, that would be awesome.

Leave a Response

Recent Blog Posts

  • The social loop between my foot and my mouth is now complete
  • A note on the Delhi blasts
  • Read-Write Culture, Lawrence Lessig, and why he should be in the Congress.
  • Experiments with publishing application activity
  • Information visualization on the web

Tweets

  • My experiment with social media addiction: I am going to stay totally off Twitter, FF, FB and Orkut for the next one week. Starting now. 2008-11-29
  • @hokiegirl I'll say watch it. Annoying: yes, offensive: yes, smarter-than-thou: yes, makes a point: yes. Also, funny. 2008-11-29
  • My request to everyone: Please watch Religulous. Watch it today if you can. It won't change what you believe, but it *will* make you think. 2008-11-29
  • More updates...


©2009 Sameer Ahuja.