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
Usage Tagged Blog Posts
Making PHP File Uploads Work For Large Files
Posted on 06/18/2013 at 01:01 pm | Viewed 19,114 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,496 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
Must Have Tool for Screen Capture: Greenshot
Posted on 02/25/2013 at 12:31 pm | Viewed 13,541 times | 0 comments
I'm attempting to better document some of the tools and utitlites I use on a daily basis to make worklife just a little bit easier. Something I find myself doing more and more (especially with my new focus on documentation) is taking screen shots.
First, for a primer on capturing your screen and saving it or emailing it to someone, please read this support post.
Free iPod to iTunes Music Transfer on Windows - iBackuper
Posted on 02/23/2013 at 11:47 am | Viewed 38,445 times | 0 comments
iBackuper is an iPod Access and Transfer Tool for Windows
My review of iBackuper: Excellent, Simple and easy to use. You can't go wrong when there are only 3 buttons.
I can restore my iTunes Library onto a new Computer using my iPod. Sure thing.
My Windows music library computer finally crashed. With its demise, all of my music files were safe. Don't worry I said. All my music is safely backed up to my iPod. Common sense, right? Well, to actually import your iPod into iTunes and make your iPod be the actual starting point for the new music library (on the PC), you can't do it in iTunes! You need software! Well, most of us need software- if all of your music is in iCloud then you wouldn't be reading this article, anyway. Right?
Avoiding Errors with Zend Lucene Search Results
Posted on 01/14/2013 at 02:34 pm | Viewed 16,173 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,280 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
Smooth Gradients in Photoshop
Posted on 10/24/2012 at 10:16 am | Viewed 14,738 times | 0 comments
Every now and then, when I look really close at a design in Photoshop, I see that one of my color gradient layers looks really bad. I didn't know what this was called, until I searched around for how to get smooth gradients in Photoshop.
Best Way To Get Transparent PNGs Without Any Hacks
Posted on 10/21/2012 at 10:27 am | Viewed 13,943 times | 0 comments
I avoided PNG images for quite a while, mainly because I could accomplish almost every task with transparent GIFs (if not, I could change the design ever so slightly). Fast forward a few years and web designs are far too complex and textured to only use transparent GIFs, plus it's so much cooler to say "ping" than "gif". Another reason I avoided using transparent PNGs was due to the ability to make IE (Internet Explorer) crash (suprise!). Finally, I avoided using PNG images on my website because their filesize was ridiculous (what I could do in 10kb using a Gif, would take 71kb as a PNG).
Read: Best Way To Get Transparent PNGs Without Any Hacks | View: Comments
Calling an Element from a Helper
Posted on 02/24/2012 at 02:07 pm | Viewed 12,653 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,534 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,746 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 19,940 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,252 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,404 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
The Funniest Error Message Ever - Thank You Eclipse
Posted on 10/18/2010 at 06:34 pm | Viewed 14,700 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
Common SSH Commands (An Idiot's Guide)
Posted on 09/25/2010 at 09:25 am | Viewed 13,248 times | 2 comments
Well, I never thought I would be saying this, but I'm starting to love using SSH to manage certain elements of my server. Now that I'm using ssh bash to make some updates to my server, I find myself constantly hunting for the simple commands. I'm going to put all the commands I need below, because I'm the idiot and it's my guide.
Read: Common SSH Commands (An Idiot's Guide) | View: Comments
Using KDiff3 as Git GUI Merge Tool on Windows XP and Windows 7
Posted on 09/23/2010 at 01:39 pm | Viewed 51,266 times | 0 comments
I've been looking for the silver bullet solution to using KDiff3 as my git mergetool on Windows (using Git GUI). I've finally got a solution that works in every Windows environment I've tried:
- Add the KDiff3 directory to your Windows System Path (e.g. C:\Program Files\KDiff3\)
- Add kdiff3 as your Git mergetool (From Git Bash, run git config --global merge.tool kdiff3)
- Add kdiff3 complete path to Git Config (From Git Bash, run git config --global meregtool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe")
- Go into Git GUI settings and set the mergetool to kdiff3 (if Git GUI doesn't pick up this setting from git config, which it should)
Read: Using KDiff3 as Git GUI Merge Tool on Windows XP and Windows 7 | View: Comments
Getting All ACL Permissions in One Lookup (CakePHP 1.3)
Posted on 09/19/2010 at 11:36 am | Viewed 21,124 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
Difference Between Truncate and Empty (Delete From) in Mysql
Posted on 06/23/2010 at 02:30 pm | Viewed 32,904 times | 1 comment
I use Navicat for administering all of my MySQL databases. It has a command that I always use- empty table. I noticed today that all along there has been a command right below it for truncate table. Hmmm. I figured this would result in the same outcome and wondered what the difference is between emptying a mysql table and truncating the same table.
Read: Difference Between Truncate and Empty (Delete From) in Mysql | View: Comments
Best Approach to Dynamic Javascript in CakePHP Views
Posted on 05/29/2010 at 12:36 pm | Viewed 23,146 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
Best Free Mysql Zip code Database
Posted on 04/20/2010 at 04:42 pm | Viewed 20,083 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.
Cache Results from Query in CakePHP
Posted on 03/24/2010 at 11:18 am | Viewed 15,219 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,812 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
Use a Plugin Element Outside of the Plugin in CakePHP
Posted on 03/13/2010 at 01:03 pm | Viewed 14,934 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,620 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
Export to PDF from Microsoft Publisher
Posted on 03/05/2010 at 10:54 am | Viewed 12,234 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. However, this would just be an "image" of the document, not the actual document with selectable text. This is how you can get a PDF with rendered text out of Microsoft Publisher...
Read: Export to PDF from Microsoft Publisher | View: Comments
Which Submit Button was Clicked in CakePHP? Use Name.
Posted on 03/04/2010 at 12:01 pm | Viewed 26,069 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
Changing the Order Sequence of CakePHP Behaviors
Posted on 02/25/2010 at 07:20 am | Viewed 13,179 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,420 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
Weird Git Error After Upgrade: Repository not found. Make sure you include the .git
Posted on 02/02/2010 at 08:18 am | Viewed 16,011 times | 0 comments
This isn't a weird error in that I've never seen it (ususally when I forget to load up Pagaent before attempting Github push/pulls). It's weird because everything was working perfectly and then I couldn't do anything from remote! I upgraded msysgit recently and hadn't tried to do any remote commands until yesterday. And I kept getting the following error in Git Gui:
Read: Weird Git Error After Upgrade: Repository not found. Make sure you include the .git | View: Comments
Using Git and Plink for SSH on Windows
Posted on 01/25/2010 at 11:11 am | Viewed 38,791 times | 0 comments
Well, I finally had an opportunity to install Git on Windows yet again. It had been quite a while since my last time installing Git on Windows, so I was a little rusty and couldn't figure out how to get Git to use Plink for SSH. It's actually quite simple and dependent on a Windows system variable.
Getting Git to use Plink for SSH on Windows
Read: Using Git and Plink for SSH on Windows | View: Comments
12 Essential Photoshop Keyboard Shortcuts
Posted on 12/21/2009 at 05:05 pm | Viewed 12,437 times | 0 comments
I remember about 7 years ago watching my friend use Adobe Illustrator. He was a communications design major and used his keyboard more than his mouse. I was blown away when I realized how much time you could save by learning keyboard shortcuts for Adobe's products. This is my list of the best Adobe Photoshop keyboard shortcuts for web designers.
Read: 12 Essential Photoshop Keyboard Shortcuts | View: Comments
CakePHP Translate Behavior - Lessons Learned
Posted on 12/15/2009 at 08:29 am | Viewed 34,586 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
Viewing Rendered Email Messages in CakePHP
Posted on 12/09/2009 at 12:15 pm | Viewed 21,009 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
Jquery Direct Descendant Selector (using the >)
Posted on 11/17/2009 at 01:08 pm | Viewed 14,710 times | 0 comments
I'd been struggling with a very simple accordion menu script. The problem was that I couldn't stop all of the links from returning false, when I only wanted to top link to return false. Let me show you my code:
$('div#sideNav li:has(ul) a').click(function() { return false; });
Read: Jquery Direct Descendant Selector (using the >) | View: Comments
Delete Dependent Just Deleted All My Records
Posted on 09/17/2009 at 10:12 am | Viewed 13,384 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,685 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));
Cakephp's Flay Class is Amazing - Examples Included
Posted on 09/08/2009 at 09:31 pm | Viewed 13,860 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
Making Valid Email (mailto) links in CakePHP
Posted on 08/25/2009 at 04:59 pm | Viewed 15,435 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
Cheatsheet for Creating .MOV Files from .VOB files (DVDs)
Posted on 07/30/2009 at 11:38 am | Viewed 11,685 times | 0 comments
Every now and again I need to take a video from a promotional DVD and put it on a client's web site. I use a handy utility that will convert almost any video file into a flash video (.swf/.flv). The hard part usually comes from having to rip the video from the DVD.
Read: Cheatsheet for Creating .MOV Files from .VOB files (DVDs) | View: Comments
Adding Anchors to Your CakePHP Generated Urls (#link)
Posted on 07/02/2009 at 09:02 am | Viewed 35,220 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
Fixing the Default HP OfficeJet Scanner Settings (which suck)
Posted on 05/28/2009 at 11:11 pm | Viewed 13,116 times | 0 comments
The default settings for my OfficeJet L7500 All-In-One Scanner suck! I thought the scanner was junk. Every photo I scanned, espcially glossy finished photos, were coming out looking like they were from a 1960s era camera: over-exposed and super high contrast. Not good! I thought I had good Photoshop skills, but even they were no match for the over-exposed mess that HP was sending into Photoshop.
Read: Fixing the Default HP OfficeJet Scanner Settings (which suck) | View: Comments
Distinct vs. Group By in MySQL (and CakePHP)
Posted on 05/21/2009 at 11:27 am | Viewed 21,594 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
Best Eclipse Feature: Link With Editor
Posted on 05/21/2009 at 09:43 am | Viewed 16,597 times | 0 comments
I use Eclipse for all of my CakePHP development work. I love that you can get code completion, class inheritance, and more by following these steps. I also loved that I could have 20 something files opened, and when I changed the active document in the editor, my PHP Explorer hierarchy would change in response.
Read: Best Eclipse Feature: Link With Editor | View: Comments
Dealing with MySQL Old-Style Passwords
Posted on 05/20/2009 at 04:37 pm | Viewed 12,601 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,145 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,684 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
Naming a Text File .htaccess on Windows
Posted on 05/13/2009 at 12:15 pm | Viewed 11,149 times | 0 comments
A big pain- you can't just name a file .htaccess through Windows Explorer. It complains that you need to supply a name! No problem.
Here's how you can name a file .htaccess (only tested on Notepad, though hopefully it will work on more):
- Load up your file in Notepad or create a new file in Notepad
- Add your .htaccess declarations
- File > Save As
- In the filename text box put ".htaccess" - with the double quotes (".htaccess" exactly)
- In the filetype select box choose 'All Files'
- Save it!
Read: Naming a Text File .htaccess on Windows | View: Comments
Making Apache Parse .html files as .php Files
Posted on 05/13/2009 at 12:09 pm | Viewed 12,401 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
Avoiding New Line Errors using Git on Windows
Posted on 05/12/2009 at 12:27 pm | Viewed 12,493 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
Getting Full Resolution Pictures out of MS Word (almost)
Posted on 04/29/2009 at 11:14 am | Viewed 14,260 times | 1 comment
People use what they know. Most of the time I get photos embedded in an MS Word document for use on a web site. My workaround to date has been to enlarge the picture (in Word) until it is as big as it gets (keeping quality) or the size I need. I would then do a print screen and paste into Photoshop.
I knew that there had to be a better way, but at least I was getting as much resolution as possible from the photo/picture. Well I came across an interesting scenario today- I couldn't enlarge the photo. I don't know if formatting was locked on it, but I didn't have time to fiddle with it. Instead I searched for a way to export embedded photos at full resolution and found this thread.
Read: Getting Full Resolution Pictures out of MS Word (almost) | View: Comments
Preformatted Text in TinyMCE <pre></pre>
Posted on 04/21/2009 at 10:26 am | Viewed 21,627 times | 1 comment
Now that I've got my blog up and running, I've been playing around with syntax highlighting of source code. I really appreciate sites that serve up code samples in a nice format, so I've tried to comply with my own version of this best practice.
Getting Geshi working, for syntax highlighting was one battle (I'll try and post what I came up with later). My real trouble came with using <pre></pre> tags for my code samples within TinyMCE. I absolutely love TinyMCE! I did a lot of research on the best JavaScript-based WYSIWYG editor oh about 5 years ago, and decided on TinyMCE and never looked back. I use it in all of my applications that require formatted HTML input (especially Site Avenger). Every now and then I will look at another editor (I know 5 years is ancient by web standards) but I've never found an editor I like more. Each editor has its quirks and I think the quirks within TinyMCE are the most manageable (as I tell my clients- even MS Word has quirks, you're just used to them).
Read: Preformatted Text in TinyMCE <pre></pre> | View: Comments
$paginator->sort() error?
Posted on 04/17/2009 at 01:32 pm | Viewed 10,913 times | 0 comments
I thought there was an error in the paginator view helper. All of a sudden I could only sort a field ascending. I (again) did a little research and came across a great thread on the CakePHP Google Group (here). Basically, as of 1.2.8120, you need (or should) specify the ModelName in your sort() function. I had only been doing sort('id'), sort('name'). Now I am doing sort('ID', 'ModelName.id') and sort('Name', 'ModelName.name'). It's a little more work having to specify the label (otherwise it defaults to ModelName.field, instead of just field).
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