Codekarate Content

By shane
Tue, 2011-05-03 14:06

I recently was tasked with creating a Drupal 6 Ubercart Payment Gateway module. I started the task off looking over various contributed payment gateway modules for Ubercart as well as looking at the payment gateway module that comes with the Ubercart module. What I found was that there are many techniques that developers use when building a payment gateway module. I am going to outline the ones that worked best for me.

By shane
Thu, 2011-04-07 23:08

I wanted to post an example of using hook_user to load some data to the user object. This simple example will just load an arbitrary value to the user object anytime a user object is loaded. You would typically load additional items by querying the database to get the information but for example purposes I just give it a simple value.

 * Implements hook_user().
function MYMODULE_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'load') {
    //typically you would use db_query or something similar here
    $account->mymodule_value = 'My value';
By shane
Tue, 2011-04-05 11:12

So I finally got around to looking into module development with Drupal 7. In fact, I really started to get my hands on Drupal 7 for the first time. I was very pleasantly surprised with the admin overlay and the entire usability of Drupal 7.

While building a module with Features, Views, and Fields (most of CCK was rolled up into Drupal 7 core with some changes and is now called Fields), I quickly ran into a problem. I wanted to do a simple query of node data. In Drupal 6 I would have accomplished this with a simple select statement. Something like:

By shane
Sun, 2011-04-03 00:24

I planned on just giving a high level overview of how I typically go about setting up a subscription based Drupal 6 website. I planned on just creating a primer for someone to look over, but I decided to give myself a challenge and see if I can create the entire site in 15 minutes.

Another thing to note is that I will start from nothing and build a simple subscription site in Drupal in 15 minutes with just the default Garland theme. I will also be writing this blog post at the same time with all the commands or actions I perform on the site. I am not sure if I will get it finished in 15 minutes, but I guess we will see.

By shane
Thu, 2011-03-24 15:22

When I first began working with forms in Drupal 6 I dove right in without reading all the documentation available on However, I soon realized using drupal_goto() inside my form's submit handler was not the correct way to do things. This is just a little bit of information on how to set form redirects correctly from in the main form function, the submit function, and even a form alter function.

From the main form function:

If you are a Drupal developer and are not using the Drupal features module to help with your workflow, you are missing out on a huge opportunity. What kind of opportunity you may ask? How about an opportunity to make your life easier, allow you to develop Drupal websites faster, and provide you with simple ways to version control your exportables (views, cck, panels, variable settings, etc). I am going to give a brief recipe of how I use features in my workflow in hopes that maybe you will get some new ideas (and perhaps send ideas my way as I am always looking to improve the development process).

If you want a complete walk through and introduction to the Features module as well as more information on crafting a Drupal development process. You can check out my 5 Secrets to Becoming a Drupal 7 Ninja Ebook.

If you are interested in a video on the Drupal 7 features module, check out my Drupal 7 Features module introduction.

By shane
Wed, 2011-03-16 22:00

So one day I wake up to a phone call from a client saying their website was broken. After looking into it, I was able to determine that the website itself was working fine, however there were now red error messages showing up on almost every page. After further looking, they were not really errors, they were PHP notices. The notices sprung up during server upgrades that migrated from PHP 5.2 to PHP 5.3. At the time, we ended up just changing the PHP error setting to no longer display notices, and the crises was averted. however looking back now we could have done it this way.

By shane
Wed, 2011-03-16 00:03

I recently had a small issue where my Drupal 6 node object did not have all the current and correct data because the node that was stored in the Drupal node cache was out of date. This is not something I have run into very often (I think only one other time before tonight), however if you run into the same problem then here is the solution:

Rather than just using:

By shane
Tue, 2011-03-15 08:26

As mentioned in a previous post, here is a quick shortened and simplified example that is similar to the code I used on a past Drupal site to create a message template. This example uses the messaging modules hook_messaging, it also declares a few token values that are passed through to the template.

By shane
Mon, 2011-03-14 20:39

So I recently ran into the situation where I was theming an Ubercart product node page and had the need to display a mini panel in the .tpl.php file. Here is the code I used to get it to display. The first code snippets went in the template.php file of the theme, while the second code snippet went in the node-product.tpl.php file.

You will need to replace "MYTHEME" with the name of your theme and "my_mini_panel" with the name of your mini panel. This can be found on the mini panels admin page (admin/build/mini-panels) under the Name column.