Articleshttp://bakery.cakephp.org/Latest Articlesen-usBreadcrumbs trail for unordered pageshttp://bakery.cakephp.org/articles/webrene/2012/04/23/breadcrumbs_trail_for_unordered_pageshttp://bakery.cakephp.org/articles/webrene/2012/04/23/breadcrumbs_trail_for_unordered_pagesI also played with $referer variable, back button usage and javascript back-functions but in the end the trac was always getting kind of mixed up by functions / methods like save, edit, etc. This Component/Helper pack will allow you to customize methods and controllers to be ignored and to display a nice, clickable trail in the form ofComponent Component Component2 This bundle consists of a C...ArticlesMon, 23 Apr 2012 15:12:08 +0000from Cake to Bakehttp://bakery.cakephp.org/articles/mainiabhay/2012/04/22/from_cake_to_bakehttp://bakery.cakephp.org/articles/mainiabhay/2012/04/22/from_cake_to_bake1. Download the latest version of Cake from http://cakephp.org/2. Go to your Download folder , Extract the folder in the same location.3. Move the folder to your application root. if you face permission denied while copy/paste, use "gksu nautilus" to open the target location.4. Rename the folder, MyCake5. Use this to change permissions, "sudo chmod -R 777 /var/www/MyCake/"6. Delete the folder n...ArticlesSun, 22 Apr 2012 23:18:10 +0000SELECT FOR UPDATE (hack) (kind of ugly but it works) (PostgreSQL and MySql)http://bakery.cakephp.org/articles/arod/2012/04/14/select_for_update_hack_kind_of_ugly_but_it_works_postgresql_and_mysqlhttp://bakery.cakephp.org/articles/arod/2012/04/14/select_for_update_hack_kind_of_ugly_but_it_works_postgresql_and_mysqlSometimes one needs to do a SELECT ... FOR UPDATE in order to preserve the integrity of our transactions. The problem can be seen easily with the following example:Suppose we have a user, an `account table` with the `account.available_money` field on it. Suppose the user has initially $100.The problem arrives if the hacker manages to concurrently run two processes ` and `save` are shown) :One p...ArticlesSat, 14 Apr 2012 04:16:22 +0000Zhen CRM: open-source CakePHP CRM applicationhttp://bakery.cakephp.org/articles/telerim/2012/04/13/zhen_crm_open-source_cakephp_crm_applicationhttp://bakery.cakephp.org/articles/telerim/2012/04/13/zhen_crm_open-source_cakephp_crm_applicationWe are pleased to announce the release of Zhen CRM, an open source CRM solution built on CakePHP.Project page: http://telerim.github.com/Zhen-CRM/GitHub project: https://github.com/telerim/Zhen-CRMWhile this does not have the complicated features of enterprise CRMs, it has the basic features that most small businesses could use - such as contacts, tasks, "deals" and a calendar.In contrast to th...Case StudiesFri, 13 Apr 2012 04:27:04 +0000CakeHtmlHelper speed up your site enabling html cache - Cakephp 2.xhttp://bakery.cakephp.org/articles/eugenioclrc/2012/04/01/cakehtmlhelper_speed_up_your_site_enabling_html_cache_-_cakephp_2_xhttp://bakery.cakephp.org/articles/eugenioclrc/2012/04/01/cakehtmlhelper_speed_up_your_site_enabling_html_cache_-_cakephp_2_xOkey, first you must have mod_rewrite enable to make the html cache working;[code]<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_METHOD} ^GET$ RewriteCond %{DOCUMENT_ROOT}/cache/$1/index.html -f RewriteRule ^$ /cache/$1/index.html [L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^$ index.php?/$1 [QSA,L]</IfModule>[/code]Now create the helper in the file View/Helper/CacheHtm...ArticlesSun, 01 Apr 2012 03:47:28 +0000ToastyCMS a CMS for people who love bread that is baked twicehttp://bakery.cakephp.org/articles/icompuiz/2012/03/28/toastycms_a_cms_for_people_who_love_bread_that_is_baked_twice_1http://bakery.cakephp.org/articles/icompuiz/2012/03/28/toastycms_a_cms_for_people_who_love_bread_that_is_baked_twice_1I didn't follow any real software process so I lack documentation. I am still working on it but I am looking for some feedback. I have included some getting started information https://github.com/icompuiz/ToastyCMS/blob/master/READMEIt is built on CakePHP 2.0.1.I am thinking about reimplementing it with cakephp 2.1.1 and using more of the cakephp conventions like plugins to support extensibilit...General InterestWed, 28 Mar 2012 17:29:49 +0000PaginationRecall for CakePHP 2.xhttp://bakery.cakephp.org/articles/Zaphod/2012/03/27/paginationrecall_for_cakephp_2_xhttp://bakery.cakephp.org/articles/Zaphod/2012/03/27/paginationrecall_for_cakephp_2_xI changed the old PaginationRecall component of mattc so that it works under CakePHP 2.x.Here's the changes code:<pre><code>?php/* * Pagination Recall CakePHP Component * Copyright 2008 Matt Curry * www.PseudoCoder.com * * @author mattc <matt@pseudocoder.com> * @version 2.0 * @license MIT * Changed to cakephp 2.x by * */class PaginationRecallComponent extends Component {var $components = array;var $Controller = null;function i...</matt></code></pre>ArticlesTue, 27 Mar 2012 20:44:12 +0000Force saving with when insert primary key valuehttp://bakery.cakephp.org/articles/doshu/2012/03/27/force_saving_with_when_insert_primary_key_valuehttp://bakery.cakephp.org/articles/doshu/2012/03/27/force_saving_with_when_insert_primary_key_valuethis workaround use the <strong>beforeSave callback.</strong><br/>beforeSave is called after cakephp decide in the current saving process in an insert or an update.<h1>put this code in the app_model:</h1><code>public function beforeSave{ parent::beforeSave; if && $opt['id']) { if) { $this-data[$this-name][$this-primaryKey] = $opt['id'];} } return true;}</code><br/><br/><h1>When you need to force the save use this:</h1><code>$this-save, array);</code><br/><br/><strong>Replace $fields wit...</strong>ArticlesTue, 27 Mar 2012 12:58:46 +0000Eclipse Code Completion in views using $thishttp://bakery.cakephp.org/articles/leoden/2012/03/28/eclipse_code_completion_in_views_using_thishttp://bakery.cakephp.org/articles/leoden/2012/03/28/eclipse_code_completion_in_views_using_thisCreate this file add to your app/View directory, refresh your project and all should work. Add in helpers as you need[php]App::uses;/** * this Helper * * @property Html $Html * @property Session $Session * @property Form $Form */class this extends AppHelper{var $Html;var $Session;var $Form;public function __contruct{$this-Html = new HtmlHelper;$this-Session = new SessionHelper;$this-Form = new ...ArticlesWed, 28 Mar 2012 14:09:59 +0000Don't forget afterFind callbackhttp://bakery.cakephp.org/articles/saidbakr/2012/03/15/don_t_forget_afterfind_callbackhttp://bakery.cakephp.org/articles/saidbakr/2012/03/15/don_t_forget_afterfind_callbackSuppose that you have Post and Comment model where Post model hasMany Comment while Comment model is belongsTo Post. Now we want to find all posts and each post's comment count, we may do the following code in posts_controller:{{{function index{ $this-Post-unbindModel), false); // Notice the above line $posts = $this-Post-find; $this-set;}}}}We used unbindModel method to improve performance by ...ArticlesThu, 15 Mar 2012 16:48:41 +0000PDO_PGSQL y CAKEPHP 2.0http://bakery.cakephp.org/articles/archermax/2012/03/13/pdo_pgsql_y_cakephp_2_0http://bakery.cakephp.org/articles/archermax/2012/03/13/pdo_pgsql_y_cakephp_2_0Comencé recientemente a utilizar el cakephp 2.x, y con la nueva versión vinieron los nuevos problemas.cree el proyecto sin inconvenientes, cocine los modelos, controladores y vistas en un soplido, y cuando eche a correr la aplicación me salto este error: Cake is NOT able to connect to the database.Database connection "SQLSTATE[08006] [7] could not connect to server: Permission denied Is the ser...ArticlesTue, 13 Mar 2012 00:19:12 +0000CakePHP internationalization and localizationhttp://bakery.cakephp.org/articles/2012/03/02/cakephp_internationalization_and_localizationhttp://bakery.cakephp.org/articles/2012/03/02/cakephp_internationalization_and_localizationFirst, it’s important to understand some terminology. Internationalization refers to the ability of an application to be localized. The term localization refers to the adaptation of an application to meet specific language requirements .[b]1-Part:[/b]First of all you need to change the Security.salt value of the config/core.php to a different value, and then create the file /app/config/config.p...ArticlesFri, 02 Mar 2012 07:41:41 +0000Cakephp application + Netbeans + Remote Access + SSHhttp://bakery.cakephp.org/articles/syl-via/2012/02/08/cakephp_application_netbeans_remote_access_sshhttp://bakery.cakephp.org/articles/syl-via/2012/02/08/cakephp_application_netbeans_remote_access_sshJust in case someone is searching for a working way of configuring remote server in Netbeans to work with cake application, here goes good tutorial: http://www.thewebshop.ca/blog/2009/07/working-with-remote-files-in-netbeans/Good luck!TutorialsWed, 08 Feb 2012 15:43:06 +0000Datetime formatter behaviorhttp://bakery.cakephp.org/articles/adael/2012/01/30/datetime_formatter_behaviorhttp://bakery.cakephp.org/articles/adael/2012/01/30/datetime_formatter_behaviorI took the idea from Rikkin post:http://bakery.cakephp.org/articles/rikkin/2012/01/26/formatos_de_fechasGive thanks to him, I only put his idea into a behavior.Here's the code: ?php class DatetimeFormatterBehavior extends ModelBehavior { private $__defaultSettings = array; function setup) { $this-settings[$model-alias] = $config + $this-__defaultSettings; $this-addDefaultVirtualFields; } functi...ArticlesMon, 30 Jan 2012 14:38:19 +0000Running CakePHP using the Facebook's HipHop compilerhttp://bakery.cakephp.org/articles/lorenzo/2012/01/30/running_cakephp_using_the_facebooks_hiphop_compilerhttp://bakery.cakephp.org/articles/lorenzo/2012/01/30/running_cakephp_using_the_facebooks_hiphop_compilerFacebook surprised the PHP community in early 2010 when announced they managed to write a compiler for PHP to produce C++ code. Being PHP the most popular language for web applications, it faces a lot of competition from other languages toposition themselves as the fastest language out there, buy this announcement was a real game changer as it is hard toargue against the speed of compiled machi...TutorialsMon, 30 Jan 2012 04:14:58 +0000Adding multilingualism to single language site without i18n and/or TranslateBehaviourhttp://bakery.cakephp.org/articles/mormy/2012/01/22/adding_multilingualism_to_single_language_site_without_i18n_and_or_translatebehaviourhttp://bakery.cakephp.org/articles/mormy/2012/01/22/adding_multilingualism_to_single_language_site_without_i18n_and_or_translatebehaviour<h2> Basic premises </h2><p>In CakePHP you have wonderful things like i18n and l10n, and TranslateBehaviour. Problem is this is only useful if you design your app from the beginning to do the translation as you go on. This presumes having separate tables for translated content and so on. But what if you want to use your contents table for all language content, your news table for all the news in all the la...</p>ArticlesSun, 22 Jan 2012 14:56:53 +0000Cakephp V2 without a database (Fixed)http://bakery.cakephp.org/articles/Primordial/2012/01/19/cakephp_v2_without_a_database_fixedhttp://bakery.cakephp.org/articles/Primordial/2012/01/19/cakephp_v2_without_a_database_fixed<p>When you want to use CakePHP without a database create the file /app/Model/Datasource/DummySource.php with the following content</p><pre>class DummySource extends DataSource { function connect { $this-connected = true; return $this-connected; } function disconnect { $this-connected = false; return !$this-connected; } function isConnected { return true; }}</pre>Next update your /app/Config/database.php file al...ArticlesThu, 19 Jan 2012 11:18:22 +0000CakePHP 2 and launchd on Mac OS X 10.6http://bakery.cakephp.org/articles/benni/2012/01/12/cakephp_2_and_launchd_on_mac_os_x_10_6http://bakery.cakephp.org/articles/benni/2012/01/12/cakephp_2_and_launchd_on_mac_os_x_10_6# The shellThe shell itself can be any shell you want and/or have already written. For details on this refer to the cake book, section [Creating a Shell]. # The command to run the scriptIn the cakebook in a section close to the one linked above, the writers propose a short shell script which makes sure the paths are set right – however, we don't need that on our shiny Mac OS systems. Instead, w...TutorialsThu, 12 Jan 2012 14:29:46 +0000Adding a TinyMCE image browser to CakePHP 2.+http://bakery.cakephp.org/articles/jwilcox09/2012/01/04/adding_a_tinymce_image_browser_to_cakephp_2http://bakery.cakephp.org/articles/jwilcox09/2012/01/04/adding_a_tinymce_image_browser_to_cakephp_2Here is the updated Model code:<code>?php App::uses;App::uses;class Imageupload extends AppModel { var $name = 'Imageupload'; var $validate = array ) ) ) ); var $useTable = false; function readFolder { $folder = new Folder; $images = $folder-read, true ); $images = $images[1]; // We are only interested in files // Get more infos about the images $retVal = array; foreach { $the_image = new File; $retV...</code>ArticlesWed, 04 Jan 2012 19:11:22 +0000TinyAuth ACL - fast and easyhttp://bakery.cakephp.org/articles/euromark/2011/12/31/tinyauth_acl_-_fast_and_easyhttp://bakery.cakephp.org/articles/euromark/2011/12/31/tinyauth_acl_-_fast_and_easy**Basic Setup**The ini file `acl.ini` will be in /Config/ and is as easy as it gets:[Tools.Countries]* = superadmin ; this is a comment [Account]edit,change_pw = * [Activities]admin_index,admin_edit,admin_add,admin_delete = admin,superadminindex = * [Users]index,search = user* = moderator,adminMost of it is probably self-explanatory.You don't even have to provide a roles table. If you don't man...TutorialsSat, 31 Dec 2011 12:30:21 +0000