Web design, programming, graphics, and pretty much anything else I care about.

Drupal 6 module development skeleton

At our Central NJ drupal group meetup, and went over some module development basics. The shell of a module I worked on I posted in the groups.drupal.org thread. http://groups.drupal.org/node/104919#comment-353479

Javascript for showing and hiding form fields based on the value of another field

This is the rather long js for making a block of fields only appear if a specific value was chosen for another field. (It made address information appear if you chose "General Public" on a registration form.) It is added as a markup field in a webform.

Report DB version in status report

When I change a field setting, primarily one of the select boxes on admin/structure/types/manage/article/display, the selected option in the form always reverts back to the original value. The setting does get changed, but when the form refreshes it reverts back. pwolanin witnesses the behavior with me. It is not browser related as it happens on every client computer and every browser. I also used web scarab to intercept the server responses and see that it is indeed returning cached values.

Multisite using alias in Apache config

People are always having issues setting up a multisite using Drupal. Part of the hangup is working out the symbolic links you have to create. Why? At the heart of it, Apache needs to find the index.php in the root of the Drupal installation, regardless of what URL is used to access it.


It doesn't matter what address you are using, as long as you do something to point Apache to your index.php file. For some people this means using a symbolic link in your Drupal root, like so:

Apache rewrite for subdirectory-based Drupal multisite

In a multisite setup where there is a mix of sites based on subdomains, as well as subdirectories, the rewrite can be more complicated. Use this for the subdirectory based sites:

Errors running update with drush, backup directory

I kept running into errors when doing updates with drush on my web servers.

Restricting access to user profile

Here is a helpful little snippet to prevent a user from accessing their own profile page, or changing their password. This is useful for cases where people are using some kind of guest account, or shared account.

WebFM and mime types

WebFM calls the deprecated mime_content_type() function which returned the file type for MP4s as text/plain rather than video/mp4. The file /etc/httpd/conf/magic had to be modified by adding 2 lines:

4   string   ftypmp42   video/mp4
4   string   ftypisom   video/mp4

To verify that this worked:

echo "<?php echo mime_content_type('/mnt/video/PA/Walzer.hi.mp4'); ?>" | php



(it returned text/plain before the change)

Drupal multisite configuration

Drupal can do the following:


All these sites can use the same Drupal installation. The key is to point all of them at the same index.php file, which is in the root of the Drupal installation. This requires either a symbolic link to connect a site sub-directory to the installation directory, or Apache modification to do it. Once the request is received by Drupal, it will know which site to retrieve. /smoke and mirrors

Drupal cookie domain

$cookie_domain = 'david.narrabilis.com';

Must be set in settings.php for FCKEditor's (CKEditor) file manager to work. Otherwise, you get a pop up error when you try to access it via the "Bowse Server" button. Like when trying to insert an image. Also, if this setting is incorrect, it can cause various things on a Drupal site to not work. For example, I could not log in to an otherwise functional site. When I tried to install another, with this misconfigured, the installation failed half way through with some mysql syntax error.