drupal 6.x

Hide Formatting Guidelines on Drupal's Comment Form

Need to hide the formatting guidelines and description that show up by default on Drupal's comment form? Try something like this:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case "comment_form":
      // begin: hide 'filtered html' input format guidelines and description
      unset($form['comment_filter']['format']['format']['guidelines']['#value']);
      unset($form['comment_filter']['format'][2]['#value']);
      // end
    break;
  }
}

Drupal - Attach a Custom Submit Handler Function to a Form

Need to add a submit handler function to your Drupal form so you can execute some custom code when a form is submitted? Yes? Well then, shuck 'em up partner, try something like this in your module:

Drupal Views Group by Field with Counts

Note, since writing this article I learned about Views Arguments 'action to take if argument not present' summary list with counts... it is definitely easier than the approach I documented below. I'll leave what I have done below because I'm not sure the summary list option will handle all cases. Someday I'll update this post to include a tutorial on how to use the aformentioned approach, someday.

Hide Local Task Menu Tabs in Drupal

Here is how you can hide certain local task menu tabs in Drupal by utilizing theme_menu_local_task. The example below demonstrates how to hide the 'View' tab on user account profile pages. This code goes in your theme's template.php file.

Retrieve a URL's HTML using CURL and Drupal's Cache

Need to get the HTML output from a URL and place it in Drupal's cache? Well then, you may do something like this:

Retrieve CCK Filefield Imagefield Default Image Path

Here is how to get a Drupal 6 CCK Filefield Imagefield default image path:

Hook into and Preprocess Drupal Messages

So after the line dancing party at the pole barn in Corn County last night, I needed to prevent/hide Drupal messages from being displayed to certain user roles under certain conditions. Luckily Betty Sue, from Corn City, told me about theme_status_messages().

After copying theme_status_messages() into my theme's template.php file and renaming the function to mytheme_status_messages, I was ready to rock.

Create and Apply a Patch to a Drupal Module

From a terminal...

Patching a Single File

Navigate to your module's directory that contains the changes you have made:

cd /var/www/my-website/sites/all/modules/custom/my_module

Create the patch file by running a diff on your OTHER module file and comparing it to your updated module file:

diff -ruN /var/www/my-OTHER-website/sites/all/modules/custom/my_module/my_module.module my_module.module > my_module.module.patch

Copy the patch file to the same directory as the file that needs to be patched:

Apply a Patch to a Drupal Module

So after rolling out a bunch of new changes to a website, which involved an update to the Date module, a bug was introduced that was not detected during testing.

Modify CCK Fields with Drupal hook_form_alter

Here is how to modify a CCK field on a node form in Drupal. In this particular example, the CCK field I am trying to modify is called 'field_news_image' and is inside a CCK Field Group called 'group_image'. The modification hides the field by wrapping a div around the field and setting the div's display to none.

Pages

Subscribe to RSS - drupal 6.x