Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home1/tylerfra/public_html/includes/common.inc).

drupal 6.x

Drupal - Send an E-mail with Custom Module Code

Here is how to send an e-mail with some custom code in your module and by utilizing hook_mail.

Add this example code snippet to your custom module where you would like to have an e-mail sent. For example, maybe you want to send an e-mail about a node when one of your module's forms are submitted.

Drupal - Run Custom Code When a Node's Workflow State Changes

Do you  need to execute some custom code when a node's workflow state changes in Drupal? Yes? Ok.

In your custom module, implement hook_workflow provided by the Workflow module and try something like this:

Drupal - Custom Node Access Example

To setup custom access control in Drupal 6, try something like this...

This example restricts access to everyone on a particular node type, unless the user belongs to a certain role or is the node author. Here is how I did it using hook_node_access_records and hook_node_grants in Drupal 6:

Drupal Services File Create Example with JSON and JQuery

Note, please read about this issue with the Services module before getting started!

UPDATE: There is security issue with the Services module prior to version 3.4. Now all autheticated service calls that use POST, PUT or DELETE need a CSRF token sent along in the request header. This article has NOT been udpated to show those changes! More Information and Workaround(s)

How to 'git rm' all deleted files shown by 'git status'

UPDATE: Thanks to user comments, it turns out the easiest way to do this is with this command:

git add -u

Otherwise, feel free to read the example below for an alternative approach...

===============================

So today I was updating the filefield module in Drupal 6 with Drush (drush up webform), this worked great, as usual. However, my Drupal site is under source control with GIT. So after updating the module and running 'git status' I was presented with a whole bunch of changes. Something like this:

git status

Drupal - File Usage MySQL Queries

Here are a few helpful MySQL queries to retrieve file usage in Drupal (perhaps via IMCE or other file management module).

Total File Space Used by a Particular User

select SUM(filesize) as total_space from {files} where uid = 123;

Total File Space Used by a Particular Directory

select sum(filesize) as total_size from {files} where filepath like '%files\/my_sub_dir\/my_other_sub_dir%';

Drupal - How to Make a Backup Copy of MySQL Database

Here is how you can make a backup copy of your Drupal's MySQL database from a terminal:

mysqldump -u my_drupal_mysql_uer_name -p my_drupal_mysql_database_name > ~/my_drupal_sql_dump.sql

I like to clear all of Drupal's caches before running the dump so there isn't a bunch of cache data in the export.

If you'd prefer to use Drush, check out this article instead: Use Drush to Export/Import a Drupal MySQL Database Dump File

Drupal Custom Time Field Select List with 15 Minute Intervals

If you need a custom time field select list with 15 minute interval options in Drupal 7, try this out when adding a new field to your content type (this will work in Drupal 6 as well):

Field: List (text)

Widget: Select list

Allowed values list:

Drupal Views Group by Field with Counts and Links - A Better Way

Alas, I came across a better way to take a bunch of rows from views, group them by a particular field, and provide a count for each.

Here is a basic example for Drupal 6 (probably very similar for Drupal 7).

Basic Settings

Style: HTML List

Fields

Node id (exclude from display)

Node title

Arguments

Node title

Drupal How to Add a CSS ID or Class Name to a Menu Item Link

Do you need to add a unique CSS ID or Class Name to a Drupal menu item link? Then you've come to the right place. Check out this example below...

Menu item link before:

<a href="/my_node_url_path">My Node</a>

Menu item link after:

<a href="/my_node_url_path" id="my_css_id" class="my_css_class">My Node</a>

How to do it...

Pages

Subscribe to RSS - drupal 6.x