Kevin Pirnie' Articles

In part I, I walked you through my server setup to achieve a 1 second load time for my site.  It is a Wordpress site, with a custom theme I developed. I gandered at the possibility of by-passing Wordpress's front-end engine, however, I found myself needing some of the built-in functionality Wordpress offers.  Items like custom posts, pages, and even posts are simple sql queries, however; widgets, shortcodes, and most plugins then become unavailable. So, I delved into the realm of research and found Wordpress core functionality offered the functionality I required, with very little performance hit; so I decided to simply extend some memcached functionality when pulling my pages/posts/widget/etc... The only thing I found that I lost was time, and in the end drastically improved the… Read More
Post revisions This is a weakness of WordPress. On this site there are over 30,000 revisions for the 14,000 posts. That makes the table bigger and it's slower to search in it. WordPress users realized this three years ago. Tip #1 We backed up the the wp_posts table and then used a simple MySQL command to remove old post revisions. This decreased the table size from 400MB to 120MB: DELETE FROM `wp_posts` WHERE post_type = 'revision' AND post_date NOT LIKE '2012-%' Long-term solution There are WordPress plugins which can limit the number of revisions per post. We think that the WordPress code should be improved and the revisions should be stored in a different table to maximize speed. You can support this on WordPress bug… Read More
Need a good way to resize your uploaded image?   While keeping the height/width ratio? Why would you need to do this?  Well, like most of you, I did not need to keep full sized images that I upload on page, and needed a good way to create thumbnails, and resize the originals down to a more manageable, more web friendly size. This will do the trick...  no words of caution, no instructions, just code... use it how you like :) <?php function ResizeImage($inputFile, $filepath, $ext, $maxWidth, $maxHeight){ /* Get some details about the image */ $srcDetails = getimagesize($inputFile); switch ($srcDetails[2]) { case 1: //GIF $source_image = imagecreatefromgif($inputFile); break; case 2: //JPEG $source_image = imagecreatefromjpeg($inputFile); break; case 3: //PNG $source_image = imagecreatefrompng($inputFile); break; case 6: //WBMP… Read More
I found myself needing a really simple way to pull in my sites menu, but also wanted the ability to have some placeholders for the links as well.  The following code should be created as a snippet, and called un-cached [[!YOUR_SNIPPET_NAME]] What's it do? Well, simply put it generates a navigation block, and throws all your ModX site page links into a hierarchal un-ordered list of link items.  As well, as generates a bunch of dynamic placeholders in case you have a need for them.  Note:  the snippet needs to be called, prior to placing any placeholders in your content. How Do I Use This? Create your template or page and place the following snippet call (make sure to replace YOUR_SNIPPET_NAME, with whatever you named… Read More
Since I am currently running into this issue right now as I type this, I though I would share my experiences with moving a ModX Revolution site from one server to another.  It is not an easy task, but can be accomplished rather easily. The first thing you will need to do is to verify that your new server has PHP and MySQL installed, along with the PDO drivers. Next step is to search through your current database and change any physical paths it may contain to point to your new directory structure on the new server.  Once you have this done you are ready to do a mysqldump, if you have access to phpMyAdmin, take the easy route and simply do an export.  Make… Read More