Sunday, April 30, 2017 07:04 am EDT

Drupal blog posts

Bri's picture

Ubuntu Crontab for Drupal 6 Sites

On rackspace cloud servers running Ubuntu, I have been using the following:

0 */3 * * * wget [URL to cron.php file]

to run cron at the 0th minute every 3 hours every day. To get in to the cron tab, SSH in to the server and run

crontab -e 
Bri's picture

Alter the output of Logintoboggan on User Registration Form

Recently I was faced with a problem that gave me a bit of trouble. I was using the Logintoboggan module to create a unified login form as well as to allow logins with username or e-mail address. In addition to using Logintoboggan, I had created a small helper module to remove and alter some of the cruft in the user registration form and the user profile form.

Bri's picture

Example of Using the D7 Batch API to Process Changes to Entities From a Select Query

The other day I decided that I needed to figure out how to use the Batch API. I have had a number of times where I needed to "fix" a bunch of nodes on a site. These are usually one time fixes such as adding a new field to the user object and needing a default value to be set for all the previous users. In most cases I would just create a standard menu callback and let it process. If it was too much to do in a single page request, I would change the query to limit the results and run it multiple times. I knew the Batch API was a better choice, but I hadn't taken the time to figure it out.

Bri's picture

How to Auto Node Title Nodes of a Certain Content Type in Drupal 7

Sometimes when you are creating a piece of content, the title field does not make sense to be filled out by the user. In these cases, its best to hide it and have it filled in automatically. Depending on your needs, the Auto Nodetitle may be able to give you everything you need.

After enabling the module, navigate back to basic editing of the content type you wish to configure, or add a new one. You will see a new option for "automatic title generation" with three options:

1. Disabled

Bri's picture

Preserving Line Breaks Using Plain Text Processing for Drupal 7

Have you ever wanted to use the plain text option under the "Text processing" selection for a textarea control on a form so that your users don't see the options that they get when you choose "Filtered text?"

Bri's picture

How To Fix Drupal 7 Blocked Account After 5 Incorrect Password Attempts

Have you ever come across the situation where you key in a password incorrectly more than 5 times? When you are using Drupal 7, you will get the following message:

Sorry, there have been more than 5 failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.

Bri's picture

Drupal Root Path To the File System

If you are ever in need of the root path of your drupal installation as a file system path, you can use the constant DRUPAL_ROOT in Drupal 7.

This might come in handy for requiring files or includes that have different paths for different environments, such as local, staging, or production sites.

For example, when working locally on a mac, the contents of DRUPAL_ROOT might contain something like:

/Users/bri/Sites/MAMP/mysite

But when I want to put that code in production on a linux box, then the content of the DRUPAL_ROOT might be:

/var/www/mysite/html

Bri's picture

Theme Files to Open in a new window based on Mime Types

There is a thread on drupal.org that describes how to theme drupal 6 filefields and Drupal 7 files to have them open in a new window based on the mime type. I am posting this here so that I can find it easier the next time I need to do so. I didn't write this code. I haven't tried the Drupal 6 code, but the thread appeared to have several people confirm that it worked. I myself can confirm that the code for drupal 7 works.

Add one of the following to your template.php file in your theme.

For Drupal 6 file fields

  
Bri's picture

Drupal 7 Views Contextual Filters to Create a Summary of Taxonomy Terms

Here I want to setup a page with a few views. I want to create a page of node teasers of some sort, perhaps with some exposed filters, but I also want a block that shows a summary of my nodes. I want the block to show how many nodes are in a particular taxonomy. This is nice to do with a taxonomy of States or "types" and acts as a "view nodes by type" action. This can be done with a regular text field as well, but if you are using a taxonomy it is a little trickier. Here are some basic instructions to create a page that looks like the following:

Bri's picture

Change the submitted variable in drupal 7

Go to: /admin/config/regional/date-time/formats/add
Create desired time format, i.e. l, d/m/Y or see http://id.php.net/manual/en/function.date.php for available options.
Add format.
Go to: /admin/config/regional/date-time
Set medium data type into the desired one.