About a month or two ago I also discovered the CakePHP development framework. Similarly, it seems to have changed my life (watch this space for my first CakePHP-based website).
Can you see where I’m going with this?
I wanted to be able to add JQuery to the CakePHP site that I am working on. It’s quite simple to do but I couldn’t really find anywhere that told me how to do it explicitly and I thought it might be worth explaining what I did here.
The first step is to have a functioning installation of CakePHP and a copy of JQuery.
You’ll need to put your JQuery file somewhere that CakePHP will be able to find it. As it turns out the best place would be
So this leaves us with a directory structure that looks something like:
Next, we need to include this file in the appropriate layout. If you haven’t done so already, it is most likely that this file will be called
default.ctp and will live in
app/views/layouts/. Now all you need to do is include the
In this case I’ve included the following line in my