MainelyDesign.com Blog

Showing articles 71 - 80 (146 total)

Best Approach to Dynamic Javascript in CakePHP Views

Posted on 05/29/2010 at 12:36 pm | Viewed 18,919 times | 5 comments

I always knew in the back of my mind that there was a better way of creating dynamic javascript than the method I was using.  CakePHP has a great function as part of the $View controller:  $View->addScript($jscript, false) will add a script block to your template header.  This is the command I use to send javascript created in a Cake view up to...

Speeding Up Cakephp's ACL Component

Posted on 05/28/2010 at 12:12 pm | Viewed 14,215 times | 1 comment

I came across a posting today that changed the performance of my application tremendously and reinforced a concept I had forgotten about- mysql indices. I didn't realize my app was running slow until I implemented the mysql indexes below- no formal benchmark testing, but I would say speed improved by about 300%.  The improvement was most...

Best Free Mysql Zip code Database

Posted on 04/20/2010 at 04:42 pm | Viewed 16,763 times | 0 comments

I'm sure every developer reaches a point when they will need to use a mysql database of zip codes in the United States.  Say you want to make a store locator and show how many miles a customer is from your store, or if you have some custom php logic that uses zip codes, you will inevitably need a mysql database of zipcodes.  The Best Free Mysql...

Controlling CakePHP Error Handling When Debug = 0

Posted on 04/19/2010 at 04:27 pm | Viewed 23,727 times | 1 comment

I finally had a client request a piece of functionality that required me to program CakePHP so I could better control the default error handling when the site is in production mode (i.e. debug is set to 0).  By default, CakePHP will throw a 404 page not found header whenever ANY errors occur on a production site with debug equal to zero.  This...

Cache Results from Query in CakePHP

Posted on 03/24/2010 at 11:18 am | Viewed 11,660 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 13,698 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 9,403 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 17,088 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 11,915 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 39,040 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...

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

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design