Whats new in CakePHP: Asset Sharing
Article posted by Joel Moss on 16 Jan 2007   |  
Back in November of last year, I wrote a short article on how to achieve global CSS, Javascript and Images using CakePHP. It was and still is a great way of sharing your assets between mutiple Cake applications, but it was only really touched upon slightly and still needed additional tweaking. Well, CakePHP 1.2 has done just that and made it soooo easy to share your assets between apps. Simply forget about my previous method and make sure you are using the 1.2 pre release of CakePHP. Now in your top Vendors directory you should notice a couple of new directories: css and js. Simply place your shared CSS files in the css directory and do the same for your javascript files, placing them in the js directory. That my friends, is it! Whenever you call a CSS or javascript file from within your views, Cake will first look for that file in your app's webroot. If it can't find it, it will look in your top vendors directory and include it if found. Zero configuration and no hacking!! Enjoy ;)

This site contains the musings of Joel Moss, and is powered by Codaset pages; a simple, yet powerful way to host your static site. Just commit and push your site to your free Git repository at Codaset, and that's it!