planet drupal

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.

Programmatically Render Image Style for Image Field with Drupal

Drupal 6

Here is a function that you can pass an imagecache preset name and a drupal image file path to and it will try to build a derivative image from the preset name and return to you the path to the derived image:

Drupal Bulk Delete Nodes and Reset NID Counter

Here is how to bulk delete a big chunk of nodes for a particular content type in Drupal. This code snippet was taken from here and modified to set a limit so php won't run out of memory and then it tells you how many nodes are still left for that content type. This is easiest to run inside the Devel's module PHP block.

Drupal How to Theme a Views Exposed Filter Form

To theme the exposed filter form on a view in Drupal:

How to Update a Drupal Module

This is a modified snippet from the discussion at: http://drupal.org/node/672472

Programmatically Display a Certain Page of Data with Drupal Views

Here is how you can programmatically load a Drupal view, then specify a particular page of data to show, then print out the view.

$what_page_to_show = 10;
$view = views_get_view('my_example_view');
$view->pager['current_page'] = $what_page_to_show;
print $view->preview();

Pages

Subscribe to RSS - planet drupal