The Bakery: Snippets http://bakery.cakephp.org/ Recent Snippets Articles at The Bakery. en-us Sat, 05 Jul 2008 19:08:58 -0500 http://validator.w3.org/feed/docs/rss2.html CakePHP Bakery mariano@cricava.com (Mariano Iglesias) gwoo@cakephp.org (Garrett Woodworth) Get the find query SQL, rather than query result http://bakery.cakephp.org/articles/view/get-the-find-query-sql-rather-than-query-result There are times when you need custom SQL queries, but where much of this query could be handled by Cake - the prime example of this is subselects. This snippet extends on the original solution provided by Yevgeny Tomenko http://bakery.cakephp.org/articles/view/extending-of-dbosource-and-model-with-sql-generator-function , but updated to support Cake 1.2 RC1 syntax. Mon, 23 Jun 2008 00:21:37 -0500 http://bakery.cakephp.org/articles/view/get-the-find-query-sql-rather-than-query-result jQuery image upload & crop http://bakery.cakephp.org/articles/view/jquery-image-upload-crop I was searching for a nice script with that i can upload and crop images. I found a nice one @ http://www.webmotionuk.co.uk/php-jquery-image-upload-and-crop/ and make it cake ready ;) So, i hope i can help you with my first Article! Here we go: Wed, 11 Jun 2008 08:40:27 -0500 http://bakery.cakephp.org/articles/view/jquery-image-upload-crop Setting SVN Ignore properties http://bakery.cakephp.org/articles/view/setting-svn-ignore-properties If you use svn, here's a very simple script that you can use to set your svn ignore properties so that your tmp folder, swap files and install specific files get ignored by svn. Wed, 04 Jun 2008 03:23:54 -0500 http://bakery.cakephp.org/articles/view/setting-svn-ignore-properties Easy AJAX Pagination Using JQuery http://bakery.cakephp.org/articles/view/easy-ajax-pagination-using-jquery This simple little JQuery function allows you to drop paginated data into your views with ease. Sat, 03 May 2008 18:50:41 -0500 http://bakery.cakephp.org/articles/view/easy-ajax-pagination-using-jquery Rebake all your admin views in one call http://bakery.cakephp.org/articles/view/rebake-all-your-admin-views-in-one-call A console script to recreate all admin views in a single call. To install ensure you are able to run the cake console commands copy the below script into /app/vendors/shells/bake_admin.php To run the script at the command line: cd /app/folder/is/here cake bake_admin help cake bake_admin all Wed, 27 Feb 2008 08:14:02 -0600 http://bakery.cakephp.org/articles/view/rebake-all-your-admin-views-in-one-call Using your application svn revision number http://bakery.cakephp.org/articles/view/using-your-application-svn-revision-number A little snippet to show how to find and use the svn revision number - to your advantage. Tue, 12 Feb 2008 04:48:00 -0600 http://bakery.cakephp.org/articles/view/using-your-application-svn-revision-number Visualize - Generate a graphic of your models/tables http://bakery.cakephp.org/articles/view/visualize-schema-task Based upon the script published by cakeexplorer (http://cakeexplorer.wordpress.com/2007/12/14/build-image-of-current-cake-schema), this script allows you to use Graphviz (http://www.graphviz.org) to generate a graphical representation of your models and/or tables To install ensure you are able to run the cake console commands install graphviz copy the below script into /app/vendors/shells/visualize.php To run the script at the command line: cd /app/folder/is/here cake visualize help cake visualize The output you'll find in the /app/config/sql folder You can see a screencast if it in action here: http://www.ad7six.com/files/visualize.mpeg Thu, 24 Jan 2008 06:32:00 -0600 http://bakery.cakephp.org/articles/view/visualize-schema-task Force login on Ajax requests http://bakery.cakephp.org/articles/view/force-login-on-ajax-requests Users often encounter situations when they want to perform an action on a web site and get redirected to login page. Application’s task is to take care of performing the requested action right after user’s successful log in. It is easy job, unless the action is requested via ajax. Sun, 02 Dec 2007 05:11:27 -0600 http://bakery.cakephp.org/articles/view/force-login-on-ajax-requests CakePHP & SMF http://bakery.cakephp.org/articles/view/cakephp-smf A quick guide on getting SMF and CakePHP working together. Uses SMF for login, session handling, even layout. Wed, 31 Oct 2007 11:14:26 -0500 http://bakery.cakephp.org/articles/view/cakephp-smf Methods for turn on/ turn off speciffic behaviors. http://bakery.cakephp.org/articles/view/methods-for-turn-on-turn-off-speciffic-behaviors Sometimes there is appear situation when you need not some action which behavior do aftomatically using event handlers. Tue, 14 Aug 2007 10:11:07 -0500 http://bakery.cakephp.org/articles/view/methods-for-turn-on-turn-off-speciffic-behaviors Haml: Markup Haiku http://bakery.cakephp.org/articles/view/haml-markup-haiku Haml takes your gross, ugly templates and replaces them with veritable Haiku. Haml is based on one primary principal: markup should be beautiful. Check out http://haml.hamptoncatlin.com/. Sun, 15 Jul 2007 04:43:28 -0500 http://bakery.cakephp.org/articles/view/haml-markup-haiku Rewrite a plugin's paths to look nicer. http://bakery.cakephp.org/articles/view/rewrite-a-plugin-s-paths-to-look-nicer Plugins are a fantastic and vastly underused tool in CakePHP! But their default paths can be strange sometimes. This article describes how to rewrite a plugin's paths using bootstrap.php. Sun, 13 May 2007 08:31:56 -0500 http://bakery.cakephp.org/articles/view/rewrite-a-plugin-s-paths-to-look-nicer Using CAKE_ADMIN for multiple user types http://bakery.cakephp.org/articles/view/using-cake_admin-for-multiple-user-types A simple hack allowing to use the functionality of CAKE_ADMIN for more than one usertype. Wed, 09 May 2007 06:05:12 -0500 http://bakery.cakephp.org/articles/view/using-cake_admin-for-multiple-user-types Thumbnails generation with phpThumb http://bakery.cakephp.org/articles/view/thumbnails-generation-with-phpthumb phpThumb is a great thumbnail generator, it can generate thumbs with GD, GD2 or ImageMagick. There are many features like crop, rotate, watermark,... see all the features on the phpThumb homepage. Wed, 09 May 2007 05:48:55 -0500 http://bakery.cakephp.org/articles/view/thumbnails-generation-with-phpthumb Taking Advantage of the Pages Controller http://bakery.cakephp.org/articles/view/taking-advantage-of-the-pages-controller Looking for a few tips on how to make the Pages Controller your new friend? Out-of-the-box it automatically maps incoming requests to their views, sets the page title, and even handles sub-pages well. But wait, there's more! Wed, 02 May 2007 00:02:42 -0500 http://bakery.cakephp.org/articles/view/taking-advantage-of-the-pages-controller