Monday, May 20, 2013 - 3:15pm -- zach

So today's our first day of DrupalCon Portland 2013, it's full of code sprints and all kinds of cool stuff. We got in last night at around 11:00 pm (UTC-8) which was around 2 back in NC. The flight was cool, flew over lots of storms and I read a lot of skymall. It's kinda amazing what is in there.

We were on the same flight as @shrop, @deeter, @tlattimore, and @bretsdunn. We dubbed it the "drupalflight".

We started off the day having breakfast at the Cadillac Cafe where I had my first "Is this local?" conversation with the waitress.

After that I registered for DrupalCon, got my t-shirt and badge, then we went to Washington Park and tried to go to the Japanese Zen garden. Unfortunately it doesn't open until 12:00 pm.

Next is lunch and getting some work done. After that we're doing a little pub crawl, if you're in PDX and want to join, hit me up on twitter or just show up.

Sunday, May 19, 2013 - 1:54pm -- zach

Right, so I'm trying to get ready for this trip, my flight (or as we're calling it the "drupal flight") leaves in 6 hours and I am no where near packed. Also, I'm pretty sure my dog isn't happy that I'm leaving, but he'll get over it.

I've already decided that I'm going to primarily use the Nexus 7 and Evernote to take notes durring the sessions. I thought about bringing the MacBook Pro a long, but I'd rather not haul this thing around with me to sessions.

I'm hoping to make a few sessions covering Jenkins, some of the higher ed focused ones, drush, rest, and a lot of the Drupal 8 talks. There's also a few on the entity api, puppet, backbone.js, and a few other things I'd like to use in my everyday life.

Friday, May 3, 2013 - 10:33am -- zach

Have you ever wanted to make your Drupal site tweet about random stuff? I did and I need to do it for an upcoming project. It's really not too difficult to accomplish this task with views bulk operations, the twitter module, and rules scheduler.

Required modules

Setting up your VBO View

The first thing you need to do is create a view that provides the list of nodes we want to tweet about but doesn't have a Page or Block display. We're only going to be using this view to provide data to rules scheduler.

Then you need to add a Bulk operations: Content field to the view and some filter criteria.

Creating the Rules Component

After you save your view you go to the Rules then Components page and click "Add new component" link on the top of the page. Select Action set as the Component plugin then click continue. After that give it a name and tags, we won't need to use variables.

After that you can start setting up your rules. Rule components (Action set) are like rules but they do not have any Events associated with the rule, that's where the Rules Scheduler module comes in. First we're going to need to setup our action to load the data from the views bulk operations view we created earlier. Select the 'Load a list of entity objects from a VBO View." under the dropdown.

Next select the View and Display you want to use for this Component, you can also send arguments to your view that supports tokens. You can also change the Variable label and Variable name for the results of the view if you want to.

After that you need to add a loop action to the Component that will loop threw the results of the view.

Then inside that loop we need to add an action, we're going to use the "Post message to Twitter" action from the Twitter module.

After that we need to setup the message, you can use token to create this and select the Sender account you want to tweet from.

After that we need to add one more action to the Component. We're going to create an action for the Rules Scheduler to "Schedule component evaluation", which basically means run the rule and schedule to run it in N number of minutes/seconds/hours/etc.

Then select the Component you want to use:

And finally schedule the evaluation date, you can do this with a fixed time or use a format that the strtotime() function can consume.

You should end up with something that looks like this:

After that you can execute the Component from the Components page:

The end result

After it runs for the first time you should see an entry on the Schedule page for it and it should have tweeted.

You may have to adjust your cron settings to make this work properly, the rule is only triggered when cron runs.

Friday, April 5, 2013 - 9:12am -- zach

One thing that bothers me about how the developer documentation is how it suggests that you should use git diff to generate your patches. That's all well and good if you have a maintainer of a project who comments the commit properly, but most of the time that doesn't happen.

When you run git diff on a repo you get output that looks like this:

$ git diff 6e04143743 --color=never
diff --git a/drupal-org.make b/drupal-org.make
index 1fda437..9429e81 100644
--- a/drupal-org.make
+++ b/drupal-org.make
@@ -1,7 +1,7 @@
api = 2
core = 7.x

-projects[ctools][version] = "1.2"
+projects[ctools][version] = "1.3"
projects[ctools][subdir] = contrib

projects[date][version] = "2.6"

That certainly is a patch, but it tells you nothing about authored the code or when it was committed.

If you use git format-patch to generate the same diff you end up with something like this:

$ git format-patch 6e04143743 --stdout
From 15936028741df0038d0f2065f0c2b09bdf2a5bd3 Mon Sep 17 00:00:00 2001
From: Zach Seifts <zach.seifts@example.com>
Date: Wed, 3 Apr 2013 15:41:01 -0400
Subject: [PATCH] Fixes issue #1960476, Update ctools module to 7.x-1.3

---
drupal-org.make | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drupal-org.make b/drupal-org.make
index 1fda437..9429e81 100644
--- a/drupal-org.make
+++ b/drupal-org.make
@@ -1,7 +1,7 @@
api = 2
core = 7.x

-projects[ctools][version] = "1.2"
+projects[ctools][version] = "1.3"
projects[ctools][subdir] = contrib

projects[date][version] = "2.6"
--
1.8.2

You end up with a whole lot more information about the commit in your patch. This way when you use git am to apply the patch you get the actual commit with the proper person attributed for their work.

Tuesday, February 12, 2013 - 9:50am -- zach

I've been working on implementing our theme in Drupal 7 and making it responsive. There are a lot of great modules out there that can help you do this, right now I'm using response.js, Omega, Breakpoints, and Picture.

One thing I've came across a few times is rendering image fields and making use of the Picture module.

$header_image = field_view_field('node', $vars['node'], $header_key, array(
  'label' => 'hidden',
  'type' => 'picture',
  'settings' => array(
    'picture_group' => 'NAME_OF_PICTURE_GROUP',
    'fallback_image_style' => 'NAME_OF_FALLBACK_IMAGE_STYLE',
    'image_link => ''
  )
);

The field_view_field function makes it really easy to render fields. I'd also take a look at hook_field_formatter_info and hook_field_info for more info on how to use the field_view_field function. Also checkout a post called Responsive Images: A Drupal Implementation that describes a great way on how to setup Breakpoints, Picture and your Image Styles. You can also export all of the configuration in a feature.

Pages

Subscribe to Front page feed