Skip to main content

drupal 6

Responsive Drupal Calendar

Drupal's calendar module is a great tool for building calendars quickly with views. However, the default theme is still using tables, blech! After some searching, I came across a sandbox module to fix this, https://drupal.org/node/1675894#comment-7903527. Like some of the user's in that thread, I did not want to add another module to my site. So, I set off to theme the calendar in a responsive way. Surprisingly, this was much easier than I anticipated. You only need to override two theme files and add roughly 88 lines of css.


Create different messages per content type with Drupal's Messaging/Notifications framework.

A recent project required me to create a different notification message per content type. To do this you can use the hook_message_alter() function to override the default message. I borrowed heavily from the code in file_message_alter()

The code I used is below:


Migrating Drupal 6 'sites/default/files' directory to 'sites/sitename.com/files'

Just wanted to post these instructions for my own sanity, and so I wouldn't lose them as I've used them numerous times over the past year. Thanks Jeff for the original post:

http://www.midwesternmac.com/blogs/geerlingguy/moving-your-drupal-files…


Drush Scripts: Running Drush Commands from Inside a Drush Shell Script

We have a website that updates numerous nodes nightly with an uploaded XML file. This XML file is then processed with Drupal's batch api, and when the XML file is uploaded manually, the script works perfectly. However, in real life, this XML file is uploaded programmatically by a script running on another server. Programmatically, the file gets uploaded and the batch begins properly, but on the successive redirects, the batch fails. This is because, the pseudo browser window from our publishing script closes.


Deleting File Attachments with Drupal's node_save() Function

Today I ran into an issue of needing to programmatically remove file attachments from a node. To accomplish this I referred to the upload_nodeapi() function and found the upload_save() function. After examining the code I found that upload_save looks for the 'remove' parameter for the file object. If $file->remove exists, the file will be deleted from the database and file system. So by adding the 'remove' parameter to the files I needed removed before calling node_save() results in the files being removed from the node upon calling node_save(). Done!