What are views in Drupal and What Awesome Things Can you Do with Views

Submitted by barnettech on Thu, 05/23/2013 - 09:31

If you're in my class and want to install views on the linux box I already have drush installed so you just need to follow the 6 steps below:  (if you're not in my class but just are following along in the book to install views on your local machine skip to after step 6 to the video -- If you're in my class and want to install views on your own machine you can use the video and instructions after step 6 as well). 

1.) use putty on a pc or terminal on a mac to login to drupalessentials.babson.edu

Drupal Web Programming Essentials, Intro and Code Editor Recommendation

Submitted by barnettech on Fri, 05/17/2013 - 09:24


Welcome to Drupal Web Programming Essentials.  This is the first video for the book Drupal Web Programming Essentials, and class for Babson College.  This video has a basic intoduction and a recommendation for a code editor so we can get started learning Drupal and all essential technologies.  The book teaches basic HTML, CSS, JavaSript, LAMP (Linux, Apache, PHP, MYSQL) and Drupal programming -- everything you need to launch a career as a web programmer / Drupal programmer.  The book is or will be available shortly.

Instead of using node_save or user_save use entity_metadata_wrapper !

Submitted by barnettech on Wed, 05/15/2013 - 10:08

In Drupal7 with entities there are some cooler ways of manipulating entity objects than using node_save and user_save, now this code for instance will allow you to add a value to the cck machine name field "field_user_terms" which takes multiple values  -- many taxonomy terms can be assigned to this field so you'll notice it's an array:

$user = user_load($current_row->uid);
$obj = entity_metadata_wrapper('user', $user);
$obj->field_user_terms[] = $current_row->tid;

Adding a node to an organic group programmatically

Submitted by barnettech on Wed, 05/15/2013 - 10:04

To add a node to an organic group programmatically this code absolutely works as of May 15th 2013.  There are a lot of articles on the web I've read with either incorrect code or outdated code:


$entity = node_load($nid); 
$values = array('entity_type' => 'node', 'entity' => $entity, 'field_name' => 'og_group_ref', 'state' => 1);
og_group('node', $row->gid, $values);


Plug for my Drupal Course I'm teaching at Babson this Summer

Submitted by barnettech on Sat, 03/16/2013 - 08:35

The course begins July 9, 2013 and ends August 22, 2013  The class is available completely remotely, or on Tuesday nights from 6 - 9:10 pm EST I will be on Babson campus presenting the class.  But Tuesday night's classes will still be broadcasted over the internet for our remote students.  Here's the course description:

Tip of the Day: have your mac command prompt tell you which git branch you're in

Submitted by barnettech on Fri, 02/22/2013 - 09:50

A colleague just shared this tip with me to have my Mac command prompt tell me which git branch I'm in:  Put the following in your .bash_profile


function parse_git_branch () {

  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'



export PS1="\h:\W \u\$(parse_git_branch)\$ "

Now my command prompt looks like this in a git directory:  belldev2:docroot barnettech (master)$

Too many connections error

Submitted by barnettech on Thu, 02/21/2013 - 10:30

If you're getting a too many connections error on your Drupal site and the site is down -- likely once a day.  Never fear, here is the answer ... this blog just suffered through that, and just upgrading Drupal to the newest version -- all modules as well, solved the problem.  Yes i don't get paid to write this blog and it suffered some down time, as it doesn't bill as top priority, so sorry for that folks.  Anyhow, might I suggest you use drush to keep your Drupal install up to date.

Run:  drush @your_alias_name up  

What to do if your Drupal site gets attacked by spammers and Black Hat SEO

Submitted by barnettech on Wed, 02/13/2013 - 11:15

So your site is being attacked with lots of spam user registrations and comments, and even nodes, what should you do.

1.)  Install the Mollom module

   -- configure mollum by going to the mollum website http://mollom.com/ and get your free api keys.  You can get a paid account for larger corporate sites.

VIM tip of the day

Submitted by barnettech on Mon, 01/28/2013 - 15:31

to delete or yank (copy) a whole function try this:

If you're on a parentheis, or curly bracket or even a quote sign you can always hit the % sign to go to the closing parentheis, curly bracket or quote sign in vim.  So you can instead do "d%" to delete all in between said quotes, curly brackets, or parenthis or you can do "y%" to yank the lines (copy) and then later go to where you want to paste those yanked lines and hit the "p" key.

Yes finally.  Great for when you're refactoring your code and moving functions around.