phyMyAdmin, mcrypt, and Centos 6: “mcrypt extension is missing” solved


Installing a current version of phyMyAdmin on Centos 6 turned out to be a grand pain. First, it turns out there are two packages in the rpmforge repo, “phymyadmin” and “phpMyAdmin”, resulting in installations of version 2 and 3, respectively.

Once past that, phpMyAdmin reports “Cannot load mcrypt extension. Please check your PHP configuration“. Well, that should be easy to fix. Just a quick “yum install php-mcrypt”. Nope. After digging around for a while, installing, uninstalling, rebooting, etc, I checked the the file /etc/php.d/mcrypt.ini.

Its contents were

; Enable mcrypt extension module

This is incorrect. I changed it to

; Enable mcrypt extension module

then restarted httpd and the problem went away. It appears that the php-mcrypt rpm, at least as of php-mcrypt-5.3.3-1.el6.rf.i686, incorrectly creates the mcrypt.ini file.

Inserting custom PHP code into a WordPress page

WordPress is a great, highly flexible content management system (CMS), but inserting a big chuck of custom PHP code that does a lot of database manipulation can be very tricky.  Go ahead and google it… I’ll wait a minute.

I’m working on a site for a grant making organization.  The website needs to include a list of recent grantees and the ability to search the list of grants by date, amount, and/or grantee.  It was easy to include this on their old HTML and PHP site.  Making this to work in the new WordPress site was a bit of a worry.  It turned out to be a lot easier than I feared.

The site is being built using the Thesis theme. One of the very nice features of Thesis is a that it supports a custom template that can be modified programmatically. What does this mean?  On the page that will list the recent grantees, I set the type to “Custom Template”.Selection_003

The Thesis custom_functions.php file then dynamically modifies the custom template for the page in question

 function custom_template() {
   if (is_page('36') ) {  // recent grants ?>
     <div id="content">
     <div id="post-<?php the_ID(); ?>" class="post_box top">
     <?php include ('grantsdb/newgrants.php'); ?>
     <div id="sidebars">
     <?php thesis_build_sidebars(); ?>
     <?php }

remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');
add_action('thesis_hook_custom_template', 'custom_template');

The actual code to display the recent grants is in grantsdb/newgrants.php.

Thesis’ custom template customizations let me re-use the code from the old website with a minimum of fuss and did not require any modifications to WordPress at all.