Recent Posts
- (09/10) Fixing Warning: the ECDSA host key for 'github.com' differs from the key for the IP addressTAGS:Web Server Admin
- (12/26) CakePHP 3 - Getting List of Column Definitions from a Table (like schema())TAGS:CakephpCake3
- (09/14) Change Order of Loaded Behaviors in CakePHP 3TAGS:Cake3CakephpWeb ProgrammingPhp
- (05/29) CakePHP 3 - Accept JSON Header Only Working When Debug FalseTAGS:Web ProgrammingCakephpCake3
- (05/23) Remove All Events from Google Calendar (Reset Calendar)TAGS:Web ProgrammingPhp
- (11/08) Google Tag Manager (GTM) Not Firing Default PageView EventTAGS:Web ProgrammingJavascriptGoogle Tag Manager
- (10/13) In PHP, how do you get __toString() Magic Method Result without calling echo?TAGS:CakephpCake3Cakephp 13PhpWeb Programming
- (11/14) Getting output from shell_exec() at all timesTAGS:Web ProgrammingWeb Server Admin
Subscribe to my feed
MainelyDesign.com Blog
Web Programming Tagged Blog Posts
Lessons Learned: Going to Mobile Website Development
Posted on 07/08/2013 at 12:39 pm | Viewed 17,989 times | 0 comments
I've recently taken the plunge and learned about CSS Media Queries and Responsive Web Design. We launched a new ordering site and made the whole website, including the checkout process, mobile-friendly. It's really opened up my eyes to the possibilities of mobile web design. I started out wondering why responsive web design was all the rage, now I prefer to order and checkout using the new Site Avenger mobile shopping templates. It's pretty easy to retrofit with an existing Site Avenger website and all new E-Commerce websites have the option of being mobile-friendly from the start.
Making PHP File Uploads Work For Large Files
Posted on 06/18/2013 at 01:01 pm | Viewed 19,396 times | 0 comments
Get PHP File Uploads Working
The first trick to having any user contributed content these days is to get PHP File Uploads working (especially with big files). Our configuration we use for our Wamp local development and on our Linux server is below.
When managing file uploads to a server, there seems to be a lot of confusion regarding optimized PHP settings and configuration. We have had some experience with this that we would like to share.
Get All Active jQuery UI Dialog Windows, then Close 'Em
Posted on 03/21/2013 at 02:36 pm | Viewed 20,603 times | 0 comments
I had a need to close all active jQuery UI dialogs on the page (yes, I have more than 1 open at a time!). You may think it's as easy as calling $('.ui-dialog').dialog('cose') but you'll throw an error. The way I've figured out how to do it (jquery UI 1.10) is pretty simple, really:
Close all Active jQuery UI Dialog Windows
jQuery UI 1.10 Tabs - Getting Index of Current Tab
Posted on 03/18/2013 at 10:00 pm | Viewed 18,443 times | 0 comments
I remember being able to get the index of the current tab very easily from jQuery UI, something like ui.panel.index. I couldn't find it in my code and figured out the way to do it with jQuery UI 1.10
Determining the Current Tab Index
Most of the documentation and examples for JQuery UI keep using the same basic code that doesn't really work if you have more than one tabbed-interface on any of your web pages. The jQuery UI documentation tells you to do this:
Speeding Up Windows 8 for Web Development (using WAMP)
Posted on 02/25/2013 at 01:33 pm | Viewed 48,704 times | 0 comments
Here is my list of optimizations and changes you can make (and I've had to make) in order to get WAMP (and CakePHP) to run faster on my Windows 8 computer.
Speed Up WAMP Web Development on Windows 8
The short list, in order of importance (stop once you are happy with your localhost web server response time and speed):
- Get the latest version of WAMP.
Start by downloading the latest wamp. I used the 64 bit version. Download WAMP here. - Edit your hosts file.
Make sure it has the proper entries, and most importantly, remove the IPv6 localhost setting. Your Windows 8 hosts file should look like this:
127.0.0.1 localhost
# ::1 localhost - Disable IP v6
A great tutorial can be found here. My advice is to disable IPv6 BOTH ways- via the network adapter and via the regedit hack. - Edit Apahce httpd.conf.
These tweaks are supposed to speed up the lstat() system calls when reading files/scanning directories. They are:
EnableMMAP On
EnableSendfile On - Edit PHP.ini
Increase the real path cache size. This helps when you have lots of files involved.
; Determines the size of the realpath cache to be used by PHP. This value should
; be increased on systems where PHP opens many files to reflect the quantity of
; the file operations performed.
; http://php.net/realpath-cache-size
realpath_cache_size = 24M - CakePHP: make sure debug is off.
Avoiding Errors with Zend Lucene Search Results
Posted on 01/14/2013 at 02:34 pm | Viewed 16,258 times | 0 comments
A common, recurring headache and complaint among Zend Lucene search processing is handling the data fields in search results.
We all like to be flexible and robust in handling the results, we may want our search to return news articles, blogs or webpage content.
Invariably, we run into problems, usually in the form of an exception
Read: Avoiding Errors with Zend Lucene Search Results | View: Comments
Integration of Cakephp Internationalization and GIT
Posted on 12/28/2012 at 12:33 pm | Viewed 21,373 times | 0 comments
We have discovered in a recent implementation of Internationalization that GIT can corrupt the POEdit generated *.po and *.mo files.
Upon committing updated files GIT by default will replace the LF with CRLF in these files. These files cannot be tampered with after generation, even viewing the files with most windows based editor may corrupt them.
Read: Integration of Cakephp Internationalization and GIT | View: Comments
CakePHP Form Security Blackhole on Large Forms
Posted on 06/28/2012 at 11:11 am | Viewed 14,838 times | 0 comments
I kept getting the White Screen of Death (WSOD). What we at Saco Design have appropriately named the behavior of the default blackhole Security Component setting. The weird issue was that I was getting the issue only on the live server. I had recently updated the live server's version of PHP to the latest 5.3.x release. However, I neglected to update my local PHP version, which was still 5.3.5.
Read: CakePHP Form Security Blackhole on Large Forms | View: Comments
Calling an Element from a Helper
Posted on 02/24/2012 at 02:07 pm | Viewed 12,748 times | 0 comments
This one caused me more than a little headache, turned out it was easily solvable.
renderElement() can be used in a helper function.
The following example worked nicely for me.
In this case I am calling and element "order_form.ctp"
$theView = ClassRegistry::getObject('view');
Forcing A Single Join in CakePHP Pagination
Posted on 10/14/2011 at 09:25 am | Viewed 22,644 times | 0 comments
The devil's in the details... I was trying to make a really simple, dreadfully easy, database join in my CakePHP web application. I've forced joins in Cake before, using the 'joins' key in the options array for find calls and paginate calls with no issue. It was late and for the first time I only wanted to use a single join. I copied the join code from a much more complex web app and pasted it into my new 'joins' conditions. And then... I got SQL errors.
Read: Forcing A Single Join in CakePHP Pagination | View: Comments
Inserting NOW() into MySQL Using CakePHP
Posted on 08/11/2011 at 11:16 pm | Viewed 14,841 times | 0 comments
Great find. If you want to insert NOW() into your query using CakePHP's save() or saveAll() functions, you can use the following expression:
$this->data['Model']['custom_date_field'] = DboSource::expression('NOW()');
Not sure how it works on MSSQL, but I will be testing that soon.
Cheers,
-Kevin Wentworth
Read: Inserting NOW() into MySQL Using CakePHP | View: Comments
Best PaginateCount for CakePHP - with Group By Support
Posted on 08/07/2011 at 05:03 pm | Viewed 20,045 times | 0 comments
I'm been muddling my way through pagination with multiple joins, and complex filtering. I finally got it all working (more on that later, maybe....) when I noticed that I couldn't paginate my results. Everything was working fine until I added a "group" parameter to the find call. Instead of getting the right count, I got a count of 1! A quick look at my sql log tables (at the bottom of the page) and I saw that I had actually returned all the mysql records that were needed! If only there was a way to use them...
Read: Best PaginateCount for CakePHP - with Group By Support | View: Comments
CakePHP Error Messages Not Showing on Form
Posted on 04/03/2011 at 12:40 pm | Viewed 20,368 times | 2 comments
I ran into an issue today that I've run into before, except I couldn't remember what I did to fix it (hence this article). I was using CakePHP validation rules to validate a user account details. The CakePHP validation was properly failing (the form data wasn't being saved) and I could tell the validate array was set correctly because the required fields were having the class .required added to them. The only problem? No error messages were being output to the form. The form validation would fail, but the CakePHP error messages were not being shown.
Read: CakePHP Error Messages Not Showing on Form | View: Comments
Sorting Paginated Results Using a Related Model Field in CakePHP
Posted on 02/06/2011 at 10:12 pm | Viewed 18,513 times | 0 comments
Time crunch, so this will be quick. I didn't want to go hunting for how to sort paginated results in CakePHP using a related model field again. I actually found my answer on Stack Overflow. The original poster had it right, so I'm not sure if it was a CakePHP bug or what (I don't have an account or I would correct it... it's on the list of to-dos though).
Read: Sorting Paginated Results Using a Related Model Field in CakePHP | View: Comments
Changing CakePHP's Model useTable on the Fly
Posted on 11/02/2010 at 05:12 pm | Viewed 18,669 times | 0 comments
I finally found an answer to/solution to something I've never been able to get around in CakePHP before: dynamically changing/setting the useTable value in a model. You can't just say $this->CakePHPModel->useTable = 'cakephp_table_name'; Instead you have to use the following function:
Setting CakePHP Model useTable Dynamically
Read: Changing CakePHP's Model useTable on the Fly | View: Comments
The Funniest Error Message Ever - Thank You Eclipse
Posted on 10/18/2010 at 06:34 pm | Viewed 14,799 times | 0 comments
In a depature from my [normally] on-topic (i.e. dry) posts I had to post this error message up here. It made me laugh! I was working on the fattest CakePHP controller known to man (over 4,000 lines, I know... not skinny) when Eclipse ran into issues. Eclipse gave a very descriptive error message, stating that it couldn't, well see for yourself:
Read: The Funniest Error Message Ever - Thank You Eclipse | View: Comments
Getting All ACL Permissions in One Lookup (CakePHP 1.3)
Posted on 09/19/2010 at 11:36 am | Viewed 21,231 times | 1 comment
The biggest hurdle I've had to overcome migrating my CakePHP application from 1.2 to the much improved 1.3 branch involves Plugins and the ACL component. A while back I noticed that my backend was kind of sluggish due to all of the ACL lookups (that happen with each request) so I optimized my ACL database tables. At that same time, I also discovered an incredible mysql query that would lookup all of the ACL permissions for a particular ARO. This setup worked great... until I started upgrading to CakePHP 1.3.
Read: Getting All ACL Permissions in One Lookup (CakePHP 1.3) | View: Comments
CakePHP 1.3 Improvements Over CakePHP 1.2
Posted on 09/09/2010 at 02:01 pm | Viewed 14,125 times | 0 comments
I've been working on upgrading my CakePHP application to cake version 1.3. It's a lot of work. I find myself constantly consulting the CakePHP manual/book for answers. There are many places to look for all of the improvements that were rolled into CakePHP 1.3 (at least coming from the 1.2 version). For my own reference, I'm creating a list of all of the manual pages that reference improvements, new features and/or different ways of doing things in CakePHP 1.3.
Read: CakePHP 1.3 Improvements Over CakePHP 1.2 | View: Comments
Global Mysql Find and Replace with CakePHP
Posted on 08/31/2010 at 09:03 am | Viewed 14,841 times | 0 comments
I'm moving my Content Management System over to CakePHP 1.3. I'll post an article about my experiences later. Today I will focus on one and only one issue with the migration from Cake 1.2 to 1.3: the change of webroot/theme/ to webroot/theme/ to serve static content. At first I was a little disapointed/scared at the prospects of making this change, but have since come to see the absolute brilliance in this approach.
Read: Global Mysql Find and Replace with CakePHP | View: Comments
Best Approach to Dynamic Javascript in CakePHP Views
Posted on 05/29/2010 at 12:36 pm | Viewed 23,253 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 the header, which is where most javascript should live. The best approach to adding dynamic javascript to your CakePHP views is to implement PHP's output buffering, combined with $View->addScript().
Read: Best Approach to Dynamic Javascript in CakePHP Views | View: Comments
Speeding Up Cakephp's ACL Component
Posted on 05/28/2010 at 12:12 pm | Viewed 18,071 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 noticeble when you are building your ACL using the CakePHP suggested method.
Best Free Mysql Zip code Database
Posted on 04/20/2010 at 04:42 pm | Viewed 20,180 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.
Controlling CakePHP Error Handling When Debug = 0
Posted on 04/19/2010 at 04:27 pm | Viewed 28,080 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 works great, most of the time. But what about when you are having database connectivity issues? Say when there are too many mysql connections to that overloaded shared hosting box? Modifed CakePHP error handling to the rescue.
Read: Controlling CakePHP Error Handling When Debug = 0 | View: Comments
Cache Results from Query in CakePHP
Posted on 03/24/2010 at 11:18 am | Viewed 15,321 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 the duration of the page load. If you want to cache query results to the file system, listen to Miles.
Setting Envelope-From in CakePHP's Email Component
Posted on 03/22/2010 at 05:56 pm | Viewed 17,929 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 = 'email@domain.com'; You have to use an as yet undocumented feature... $this->Email->additionalParams;
Read: Setting Envelope-From in CakePHP's Email Component | View: Comments
2 Neat Little PHP Tricks
Posted on 03/16/2010 at 04:15 pm | Viewed 12,582 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 Function to Validate Bank Routing Numbers
Posted on 03/16/2010 at 04:10 pm | Viewed 22,361 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:
Read: PHP Function to Validate Bank Routing Numbers | View: Comments
Use a Plugin Element Outside of the Plugin in CakePHP
Posted on 03/13/2010 at 01:03 pm | Viewed 15,011 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 app-wide elements or themed elements folder.
Read: Use a Plugin Element Outside of the Plugin in CakePHP | View: Comments
Create a Checklist Group or Related Checkboxes in CakePHP
Posted on 03/05/2010 at 12:38 pm | Viewed 43,722 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 a little convoluted.
Read: Create a Checklist Group or Related Checkboxes in CakePHP | View: Comments
Which Submit Button was Clicked in CakePHP? Use Name.
Posted on 03/04/2010 at 12:01 pm | Viewed 26,148 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 be in $this->data, but it's easy enough to get...
Read: Which Submit Button was Clicked in CakePHP? Use Name. | View: Comments
PHP Break Out of All Foreach or While Loops
Posted on 02/25/2010 at 02:44 pm | Viewed 23,409 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 surprised it took me this long to use it!
Read: PHP Break Out of All Foreach or While Loops | View: Comments
Changing the Order Sequence of CakePHP Behaviors
Posted on 02/25/2010 at 07:20 am | Viewed 13,258 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 "hardcoded" behavior to run after the dynamically attached behavior. Here's what I did:
Read: Changing the Order Sequence of CakePHP Behaviors | View: Comments
Getting a List of Database Tables in CakePHP
Posted on 02/23/2010 at 12:22 pm | Viewed 18,522 times | 1 comment
I ran into an interesting problem today. What I wanted to do was know if a table didn't exist in my CakePHP application. What happens- a cakeError is thrown everytime a database table doesn't exist. This is really annoying...I think it would be beneficial to be able to tell Controller::loadModel() to return false instead of an error message. That's not the case. Here's how I got around it (with thanks to Miles Johnson):
Read: Getting a List of Database Tables in CakePHP | View: Comments
CakePHP Translate Behavior - Lessons Learned
Posted on 12/15/2009 at 08:29 am | Viewed 34,691 times | 5 comments
I've been working on setting up a multi-lingual web site for one of my clients. I was excited at the opportunity to finally use CakePHP's built-in internationalization and locale functions. However, I ran into some issues that I'm sure other newbies to internationaliztion will run into as well. Here's some take-backs of what I learned while using the Translate Behavior in Cake...
Read: CakePHP Translate Behavior - Lessons Learned | View: Comments
Upgrading Jquery UI Tabs and it Stopped Working
Posted on 12/09/2009 at 08:16 pm | Viewed 12,961 times | 0 comments
I was upgrading the version of Jquery UI that I use with Site Avenger. The last time I was in a rush, nothing seemed to work and I rolled the changes back. This time, I took the time and decided to finally make this Jquery UI upgrade happen. This time everything went swell, except my Jquery UI tabs plugin stopped working. WTF?
Read: Upgrading Jquery UI Tabs and it Stopped Working | View: Comments
Viewing Rendered Email Messages in CakePHP
Posted on 12/09/2009 at 12:15 pm | Viewed 21,097 times | 1 comment
For a while it's bugged me that I wasn't able to see the rendered output of my email messages that are sent using the CakePHP email component. I would change my code to use a remote smtp server but I still had to send messages. Well, I finally figured out how to "debug" my emails sent using CakePHP. Thanks to this posting for finally putting all the pieces together...
Read: Viewing Rendered Email Messages in CakePHP | View: Comments
Cool Stuff with CakePHP: Cryptable Behavior
Posted on 11/20/2009 at 11:19 am | Viewed 12,184 times | 0 comments
There is so much cool stuff out there that's already been done with CakePHP. In an attempt to catalog it for my own use later, I'm going to start creating blog posts that highlight cool behaviors, components, etc. for CakePHP. This is the first one.
From the Bakery: "A behavior that will automatically encrypt/decrypt specified fields in a model, using your choice of cipher, key, and IV."
Read: Cool Stuff with CakePHP: Cryptable Behavior | View: Comments
Auto Columns with Columnizer - My New Favorite Jquery Plugin
Posted on 09/30/2009 at 10:37 am | Viewed 21,957 times | 2 comments
I was about to start coding a CakePHP helper that would analyze a bulleted list and split it into columns. Starting to think about how I would approach this problem, my head began to hurt. Then I found an awesome jQuery plugin- columnizer.
Read: Auto Columns with Columnizer - My New Favorite Jquery Plugin | View: Comments
A Really Good Implementation of Captcha
Posted on 09/22/2009 at 02:45 pm | Viewed 11,637 times | 0 comments
Awesome Captcha Implementation
I just experienced a version of Captcha that I actually like. Instead of having to type in jumbled letters and phrases or answering simple questions, Service2Client actually asks you to identify the color of the letter in a certain position. Not only does it fool spambots (I would assume anyway) but it's pretty easy to understand.
Read: A Really Good Implementation of Captcha | View: Comments
Delete Dependent Just Deleted All My Records
Posted on 09/17/2009 at 10:12 am | Viewed 13,483 times | 0 comments
Oh man! I just deleted all my database records using $model->del($id) with dependent=>true in the model association. That wasn't supposed to happen! It turns out to be an issue with how I specified my model association. What's weird is that everything works fine except when I go to do the delete with cascade set to true.
Read: Delete Dependent Just Deleted All My Records | View: Comments
Date Input Using Cakephp Form Helper
Posted on 09/09/2009 at 03:29 pm | Viewed 32,785 times | 3 comments
I always forget what exactly needs to happen in order for CakePHP's form helper to work with date input fields. I'm sick of tearing through old source code and looking at the official CakePHP docementation site. Here's how to get it to work...
Date Inputs Using the Form Helper:
$current_year = date('Y'); $max_year = $current_year + 2; echo $form->input('dateSelectBoxes', array('type'=>'date', 'selected'=>$unix_timestamp, 'empty'=>true, 'minYear'=>2009, 'maxYear'=>$max_year));
Invalid Date Value Error in MySQL
Posted on 09/09/2009 at 02:26 pm | Viewed 12,752 times | 0 comments
I ran into an interesting issue with valid dates and MySQL on Windows. I wrote a CakePHP import function that basically moves MySQL data from one DB to the other. I never thought that I would see an error related to an invalid date, but I did.
What determines if a date value is invalid (read: warning) or unacceptable (read: error)?
Cakephp's Flay Class is Amazing - Examples Included
Posted on 09/08/2009 at 09:31 pm | Viewed 13,970 times | 0 comments
If you haven't checked out CakePHP's Flay class, check it out. It's one of the best utility classes for text output in CakePHP.
I just noticed that my blog was using the same META description for all of my blog entries- not good for SEO. Instead, I want to pull a fragment of the article copy and use that as my META description. I currently use this convoluted way to get my summaries from the article copy, so I decided to try using the Flay class. I've used it before but I'm glad I revisited it... it's amazing!
Read: Cakephp's Flay Class is Amazing - Examples Included | View: Comments
Using Exif in PHP on Windows
Posted on 08/28/2009 at 09:40 am | Viewed 12,732 times | 0 comments
I'm trying to use the exif functions in PHP on my Windows XP computer. I want to read the meta data that is recorded by my digital camera (exif - exchangeable image file format). I like the idea of storing that exif data in the database, so it's searchable. I wasn't having any luck with exif_read_data(), but finally found this posting.
Making Valid Email (mailto) links in CakePHP
Posted on 08/25/2009 at 04:59 pm | Viewed 15,518 times | 0 comments
It's easy to make an email address using the HTML's helper link() function. All you need to do is have an email address appended with the string 'mailto:' (just like in regular ol' HTML).
Here's my quick and dirty function to attach it if it doesn't exist:
if(stristr($image['link'], '@') and stristr($image['link'], 'mailto') === false) { $address = 'mailto:'. $image['link']; } else { $address = $image['link']; } echo '<p>'. $html->link($image['link'], $address) . '</p>';
Read: Making Valid Email (mailto) links in CakePHP | View: Comments
Changing Filetypes Shown in SWF Upload File Browser
Posted on 08/25/2009 at 04:17 pm | Viewed 16,672 times | 0 comments
It's easy to change which file types are allowed to show up (and are displayed) when you browse for files to upload through SWF Upload. SWF Upload makes it easy to upload multiple files in PHP.
I just had to hunt through some source files until I found this in my SWF Upload config. (goes in the new SWFUpload() function)
Read: Changing Filetypes Shown in SWF Upload File Browser | View: Comments
Network Solutions' Flawed .htaccess and Mod_Rewrite Rules Implementation
Posted on 08/06/2009 at 02:38 pm | Viewed 34,484 times | 7 comments
I can't believe it! I spent hours trying to get the mod_rewrite rules working in .htaccess on Network Solutions' servers. Everything I tried didn't work. Using the default .htaccess (from Cake distribution) failed. I've used the distribution on several servers and never had any issue with the rewrite rules. However, Network Solutions's mod_rewrite works differently than [all] other servers.
Read: Network Solutions' Flawed .htaccess and Mod_Rewrite Rules Implementation | View: Comments
Using Between with Date Ranges in Proper DB Date Format
Posted on 07/09/2009 at 11:56 am | Viewed 18,318 times | 0 comments
I need my CakePHP apps to run on both LAMP and Windows IIS using MSSQL Server. Usually this isn't a problem because CakePHP does such a good job of database abstraction and database independence. However, I came across a scenario the other day where I needed to select a date range using the BETWEEN SQL command.
Using CakePHP's BETWEEN function for date ranges
Read: Using Between with Date Ranges in Proper DB Date Format | View: Comments
Adding Anchors to Your CakePHP Generated Urls (#link)
Posted on 07/02/2009 at 09:02 am | Viewed 35,330 times | 2 comments
This may seem simple and trivial, but it took me a little while to figure out. If it saves someone a little trial-and-error then great (I know I won't forget how to do it).
I needed to create a redirect in CakePHP that redirected to an inline, on-page anchor- <a name="destination">Scroll to Here</a>. Typing the link directly into the address bar of the browser, it would need to look like this: http://www.mainelydesign.com/blog/view/1219/#destination. The #destination is what I needed to figure out how to append to the redirected url. Turns out it was easy...
Read: Adding Anchors to Your CakePHP Generated Urls (#link) | View: Comments
Using CakePHP's Set Class to Make Select List Options
Posted on 06/19/2009 at 11:22 am | Viewed 13,220 times | 0 comments
If you haven't become familar with any of the functionality of the CakePHP's Set class, I highly recommend you take a peak. I don't know too much about it and really only learn about it as I go. Well, I finally found out how to do something that used to take several lines of code: creating options for a select list that includes the Model.id as the key, but has a concatenated string for the value, like 'Model.name - created by Model.userName'.
Read: Using CakePHP's Set Class to Make Select List Options | View: Comments
Changing the CakePHP Model Schema on the Fly
Posted on 06/11/2009 at 10:28 am | Viewed 14,218 times | 0 comments
I have an interesting way of dynamically changing a model's validation on the fly. I have a standard approach that involves contact forms, contest entries, etc. using a database to store which fields should be on a form. I tweaked this over time, and recently needed to change the schema from text, which all answers have been up to this point (and IS the DB field type), to a type of date. I kept getting the error 'preg_replace expects parameter 2 to be a string, array given'. Once I got the right schema, the errors went away.
Read: Changing the CakePHP Model Schema on the Fly | View: Comments
Displaying phpinfo() without CSS styles
Posted on 06/09/2009 at 10:18 am | Viewed 23,312 times | 1 comment
I wanted logged in users to be able to see the output from phpinfo(); within Site Avenger. The problem with using phpinfo() is that it outputs a full HTML page, CSS styles and all. In the past this has been fine, but now I wanted to show the phpinfo() within the Site Avenger layout and CSS styles. I came across a simple, yet highly effective solution...
Read: Displaying phpinfo() without CSS styles | View: Comments
Getting the File Path to the Vendor Folder
Posted on 06/08/2009 at 04:47 pm | Viewed 14,297 times | 0 comments
I'm trying to use a library within my CakePHP application that needs a variable defined that contains the complete file path to the vendors folder. This can be solved one of two ways- modify the library (which I don't want to do) or use the Configure::corePaths() function in CakePHP.
Best Option - using Configure::corePaths()
Read: Getting the File Path to the Vendor Folder | View: Comments
Distinct vs. Group By in MySQL (and CakePHP)
Posted on 05/21/2009 at 11:27 am | Viewed 21,693 times | 2 comments
An interesting problem- I am returning a list of files that have already been uploaded, so the user can link to an existing file. This creates a new record (duplicate record). The next time the user goes to select a file, there will now be two entries for the same file. DISTINCT to the rescue, or so I thought.
DISTINCT applies to the whole select statement
Read: Distinct vs. Group By in MySQL (and CakePHP) | View: Comments
Dealing with MySQL Old-Style Passwords
Posted on 05/20/2009 at 04:37 pm | Viewed 12,684 times | 0 comments
I ran into a problem I've seen before- Client does not support authentication protocol requested by server; consider upgrading MySQL client. Last time I came across this MySQL error, it was a simple query to fix the issue (from dev.mysql.com):
UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd') WHERE Host = 'some_host' AND User = 'some_user'; FLUSH PRIVILEGES;
Read: Dealing with MySQL Old-Style Passwords | View: Comments
Changing Display Options in Model::find('list')
Posted on 05/19/2009 at 10:49 am | Viewed 14,246 times | 0 comments
I wanted to change the displayed field that Cake automatically returns with a Model::find('list'). If you have a database column named title or name (I'm not sure of the full list), CakePHP will automatically return an array index by Model.id => Model.name. This usually works, but today I'm working with a database table that doesn't use that field- it's a table of uploaded files and uses the columns named 'src' or 'alt' to display information to the user. I forgot how to do this, so I'm posting it for reference.
Read: Changing Display Options in Model::find('list') | View: Comments
Getting the CakePHP Version in Your Code
Posted on 05/14/2009 at 10:57 am | Viewed 18,769 times | 0 comments
I was sick and tired of having to FTP into my accounts and view the VERSION.txt file that comes with the Cake core to figure out what version of Cake I was running. I did a quick search but wasn't finding anything. I was about to dig in and hack something together, but tried the CakePHP API as a last resort. Bingo!
Read: Getting the CakePHP Version in Your Code | View: Comments
Making Apache Parse .html files as .php Files
Posted on 05/13/2009 at 12:09 pm | Viewed 12,516 times | 0 comments
When re-designing a site, or somehow being locked into a given web site structure that uses .html (or .htm) file extensions, it's a good idea to keep the file names the same (especially if the site has been around a while and has good search engine visibility). Think you can't use PHP on .html or .htm web pages? Think again. With apache it's as easy as modifying the .htaccess file.
Read: Making Apache Parse .html files as .php Files | View: Comments
Keep Old Settings When Upgrading Eclipse
Posted on 05/12/2009 at 01:02 pm | Viewed 12,264 times | 0 comments
I decided to upgrade my version of Eclipse to 3.4 (Ganymede) mainly so I could use the Git plugin. I wanted to migrate my settings from one install to the other. I know I had done this before, when I upgraded from 3.2 to 3.3, but forgot how. So I don't have to scratch my head so much next time, here is how you can move your settings after you upgrade your version of Eclipse.
Read: Keep Old Settings When Upgrading Eclipse | View: Comments
Avoiding New Line Errors using Git on Windows
Posted on 05/12/2009 at 12:27 pm | Viewed 12,587 times | 0 comments
I'm finally working on moving my code over to a version control system. I've tried several times over the past few years to start using Subversion, but I never quite got into it. After hearing so much about Git, I decided I needed to start using it. Luckily, most people tell you to forget everything about Subversion when using Git- no problem there!
Read: Avoiding New Line Errors using Git on Windows | View: Comments
Pagination with MSSQL in CakePHP
Posted on 05/07/2009 at 04:36 pm | Viewed 16,888 times | 0 comments
One thing, and there are a few, that I can't stand about having to use PHP and MSSQL Server together is the lack of support for pagination. With PHP and MySQL- no problem use limit. MSSQL- can't do it without all these ugly sub-queries. I have to give it to the CakePHP developers though, for the built-in support for pagination in MSSQL. Albeit it is flawed, it works.
A tale of caution: naming CakePHP "view" functions
Posted on 05/06/2009 at 05:13 pm | Viewed 14,338 times | 2 comments
Spoiler: functions that generate a view must be named using lower_case_with_underscores()
I just ran into a very interesting problem. I was testing out some of my plugins to make sure they were still working with Cake version 1.2.2.8120. They worked fine except for one function. I had a form that updates a shopping cart, changing the quantities of products placed in the cart. When I hit the submit button to change the quantities, I was getting redirected to my site root.
Read: A tale of caution: naming CakePHP "view" functions | View: Comments
Checkbox - setting the default state
Posted on 04/17/2009 at 08:31 am | Viewed 14,883 times | 0 comments
I ran across a rather simple problem (I thought) that took a little searching to figure out. All I had to do was create a checkbox form input that I wanted to have checked by default. I tried 'default'=>'checked', which didn't work. I also tried 'checked'=>true and 'checked'=>1, but that works every time, even if validation fails and the user had unchecked the checkbox, it will be checked again (Not good usability).
Importing an Excel file into CakePHP
Posted on 04/16/2009 at 02:42 pm | Viewed 33,690 times | 0 comments
I needed to be able to upload an excel file, parse the file, and then add each row as a separate database entry. I had this working for a CSV file using the php built-in function fgetcsv(), but the client switched to using an excel file (instead of direct PHP access to the in-house database, we decided to have the client upload a CSV/Excel file).
Full Tag List
- Cakephp
- Web Programming
- Site Avenger
- Excel
- Csv
- Database
- Saveall
- Vendors
- Import
- Truncate
- Empty Table
- Forms
- Habtm
- Usage
- Tinymce
- Geshi
- Usability
- Upgrade
- Graphic Design
- Internet Marketing
- Software
- From The Hip
- Midcoast Magnet
- User Group
- Component
- Mssql
- Git
- Apache
- Seo
- Htaccess
- Mysql
- Eclipse
- Gear
- Photoshop
- Php
- Css
- Iis
- Web Server Admin
- 404 Errors
- Iisreset
- Web Design
- Hack
- Internet Explorer
- Ie
- Firefox
- Forum Answers
- Jquery
- Swfupload
- Windows
- Example
- Links
- Tutorial
- Errors
- Behaviors
- Cakephp 13
- Humor
- Music
- Jquery Ui
- Ui
- Wamp
- Cloudfiles
- Setup
- Javascript
- Responsive
- Quick Tip
- Cake3
- Foundation
- Google Tag Manager