MainelyDesign.com Blog

Showing articles 71 - 80 (142 total)

Cache Results from Query in CakePHP

Posted on 03/24/2010 at 11:18 am | Viewed 10,443 times | 0 comments

I have a HUGE query that I wanted to cache.  I love CakePHP's caching functionality out of the box, but one thing is missing- you can't cache the results of a query.  Let me clarify.  You can cache the reults of a query, but only for that instance of a page load.  Using $this->cacheQueries only caches the query to memory, which only lasts for...

Setting Envelope-From in CakePHP's Email Component

Posted on 03/22/2010 at 05:56 pm | Viewed 12,422 times | 1 comment

I've setup a form that allows customers to sign up for an email newsletter and receive a coupon. I wanted to be able to track the bounced messages in case a legitimate customer's coupon was bounced for whatever reason. As I've learned, setting up the "return-path" for an email message isn't as simple as setting $this->Email->return =...

2 Neat Little PHP Tricks

Posted on 03/16/2010 at 04:15 pm | Viewed 8,646 times | 0 comments

In writing a function to validate bank routing numbers , I came across two simple techniques, that I know I will need to use again: PHP Trick 1: Remove All Characters Except Numbers from a String A simple little regex does the trick: $routingNumber = preg_replace('[\D]', '', $routingNumber); PHP Trick 2: Loop Through a String Character by...

PHP Function to Validate Bank Routing Numbers

Posted on 03/16/2010 at 04:10 pm | Viewed 15,388 times | 0 comments

I needed to validate that a Bank Routing Number was valid, much like the algorithms out there to check if a Credit Card number is valid.  I did a little searching and didn't find a PHP function that would do the trick.  I decided to write my own, based on this javascript function , and publish it for anyone who wants to use it: Function to...

Use a Plugin Element Outside of the Plugin in CakePHP

Posted on 03/13/2010 at 01:03 pm | Viewed 10,665 times | 0 comments

Quick note- I had an element .ctp file that was part of a plugin.  I wanted to render that element across my entire Site Avenger site, including non-plugin layouts and themes.  I found out that you can send $this->element() (formerly $this->renderElement()) a 'plugin' parameter to accomplish this... otherise CakePHP will only look in the...

Create a Checklist Group or Related Checkboxes in CakePHP

Posted on 03/05/2010 at 12:38 pm | Viewed 36,572 times | 1 comment

This is an interesting one.  I needed to create a group of checkboxes.  In my mind, it's just like a radio button group, except with checkboxes.  The only difference should be that with radio buttons you can only select one, while with a checkbox group you should be able to select as many as you want.  To achieve a checklist group in CakePHP is...

Export to PDF from Microsoft Publisher

Posted on 03/05/2010 at 10:54 am | Viewed 8,174 times | 0 comments

I have a client that sends me newsletters in Microsoft Publisher format.  I wanted to output the newsletter as a PDF, but wanted to keep the text for SEO and so users can copy and paste the text if needed.  Microsoft Publisher doesn't have an export to PDF function, so usually I would just do a File > Print and select Adobe PDF as the printer. ...

Which Submit Button was Clicked in CakePHP? Use Name.

Posted on 03/04/2010 at 12:01 pm | Viewed 20,205 times | 2 comments

If you want to have multiple submit buttons that make a form do different things there's a simple way to do this.  The name of the submit button that was clicked by the user will be sent (via POST) with all the other POSTed data.  This is very handy if you want to have a cancel button and continue button. In CakePHP the name of the button won't...

PHP Break Out of All Foreach or While Loops

Posted on 02/25/2010 at 02:44 pm | Viewed 16,919 times | 0 comments

Let's have some fun with PHP's break command... I didn't think it was possible.  I just learned (I've been programming PHP for like 7 years) that you can instruct break how many levels of nesting to break out of!  I'm not surprised that break in PHP allows you to specify the number of loops (or switch statements) to break out of, but I am...

Changing the Order Sequence of CakePHP Behaviors

Posted on 02/25/2010 at 07:20 am | Viewed 8,823 times | 0 comments

For reasons too long to explain in this post, I have two behaviors that are run on the same pieces of data (a translate behavior and a settings import/export behavior).  One behavior is attached to the model using var $actsAs, while the other behavior is attached dynamically, during runtime using $this->attachBehavior();.  I needed the...

    4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12   

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design