Blog - Drupal

Customizing CCK Date Fields in Templates

I needed to print a date field within a node template in a few different formats, but I was dealing with a multiple date field. After exhausting my research attempting to use the dateapi to do so, I found a great solution of simply passing my field through content_format(). The only drawback is that this functionality rides on this patch. Once applied though, you can print your dates easily using the following code, without the worry of manually calculating timezones or overriding api functions.

Get a Taxonomy Term by Name & Vocabulary in Drupal 6

While developing a site with a master taxonomy driving the navigation, I found a need to return taxonomy data specific to the master taxonomy. Unfortunately, Drupal 6 does not have a native function to do so.

Remove Orphaned Actions from Drupal 6 & 7

I first noticed this issue when using Drush to enable a module. Drupal core will present a warning displaying something along the lines of:

orphaned actions (comment_publish) exist in the actions table. Remove orphaned actions

The answer wasn't readily Googled, but after some quick digging I found 2 solutions.

Method 1

Login as user 1 aka 'admin' and visit: http://yourwebsite.com/admin/settings/actions/orphan.

Mass Delete Nodes By Content Type

Using this method, you can easily mass delete nodes from your site by content type. Also, feel free to modify the SQL for your own purposes.

To use this code, you will need a custom module. As a best practice, I always create a site module for instances just like this. Within your module folder, create a 'module_name.install' file and place the following code within it.

Export Views to Code with a Custom Module

As a starting point for my new blog, I'll walk you step by step on how to export your views to code. Before we begin though, I bet your first question is:

Why?

Views are stored in the database and therefore can not be put into revision control. Like much of the Drupal system, the meat-and-potatoes of your website are stored in the database, and Views are no exception. If you should ever need to make a change to a view, you have nothing to roll back to, at least not without restoring a database backup, which is just silly.