Apr 18 2016
Apr 18

In our last post we talked about how the Drupal Community is supporting Drupal 6 after its end-of-life and what that means for your Drupal 6 site.  In this post we’ll get a bit more technical and talk about what exactly you need to do to keep your website up to date.

Step #1: Getting an accurate report of your site’s modules and themes

Ever since the Drupal 6 sunset date, your website’s report of Available Updates at /admin/reports/updates has been telling you that everything is unsupported and should be uninstalled.  That’s not very helpful :-)

Drupal 6 Update module report

So the first step is to get the myDropWizard module.  This is provided free (libre) to the Drupal Community by one of the Drupal LTS vendors. The main purpose of this module is to show whether a module is supported by the Drupal 6 Long-Term Support (LTS) vendors, so you’ll know if it’ll be getting security updates going forward.

Drupal 6 MyDropWizard report

Ahhh, that’s better.

Now you can continue to manage security updates for modules and themes just like you always have.  But there are some significant gotchas.

How problems are found and fixed

When vulnerabilities are found they will be posted as issues in the Drupal 6 LTS project.  Once the issue is  fixed, and if the module maintainer is still maintaining the D6 version, then the maintainer will simply release a new version, just like normal.  But if the maintainer is no longer maintaining it, then new releases are made on Github.  Drupal Core is no longer receiving any new commits on the 6.x branch,  so new releases will be made to the Pressflow project, also on Github.

How to obtain new versions

If new releases are scattered across Drupal.org and Github, the question becomes: How do we easily obtain new versions?  Assuming that you run security updates with Drush, then you can use the --update-backend=mydropwizard flag when calling any of Drush’s Project Management commands (pm-download, pm-refresh, pm-updatedstatus).  The MyDropWizard backend will automatically obtain the project from Github or Drupal.org.

New Drush

But this brings a new problem: The --update-backend flag only works with Drush 7 or later.  On a server that’s running Drupal 6, chances are high that it’s using Drush 6, and chances are also high that it’s using an old version of PHP (like 5.3.3 that is bundled with Debian/Ubuntu).  The old version of PHP means that you can’t upgrade to the latest Drush 7 (7.2.0).  But there’s a fix on the way for that.

Switching to Pressflow?

Since new releases are no longer made to Drupal Core, and only to Pressflow, this creates a bit of a dilemma for sites that are not running Pressflow.  In those cases it’s probably more cost effective to manually apply patches rather than move to Pressflow.  There’s a couple ways to be notified of these commits:

Add-on modules

The final tricky area that we’ve found is with modules that extend Update Status module. There’s two in particular that we use often: Update Exclude Unsupported, and Update Status Advanced Settings — neither of these will work anymore.  Instead you’ll need to implement hook_mydropwizard_status_alter().

/**
 * Implements hook_mydropwizard_status_alter().
 */
function mymodule_security_mydropwizard_status_alter($projects) {

  // Projects determined to be okay for this particular site.
  $projects_deemed_okay = array(
    // This is okay because of the finglewabble.
    'foo', 
    // This is okay because of hard-coded site configuration. 
    'bar',
  );
  foreach ($projects_deemed_okay as $module) {
    if (isset($projects[$module])) {
      $projects[$module]['status'] = 'deemed-okay';
      $projects[$module]['extra'][] = array(
        'class' => 'deemed-okay',
        'label' => t('Deemed okay'),
        'data' => t('This project was analyzed and determined to be acceptable to run on your site.'
      );
    }
  }
}

Conclusion

I’m sure there will be a few more hiccups along the way, but this should get you started.

Image by: Henri Bergius

Apr 08 2016
Apr 08

Those of you who still have a Drupal 6 site are by now aware that you need to do something with it since this version is no longer supported.  Your options in short are:

  • Upgrade to Drupal 7
  • Upgrade to Drupal 8
  • Choose one of several options to limit your vulnerability (e.g. convert the site into a static HTML website, or close logins to all but a handful of trusted people and harden the security of the login form)

But that’s a big decision.  What do you do until you’ve decided which path to choose?  Now that Drupal 6 is past its sunset date, is your site suddenly vulnerable to having its data stolen and being turned into a spam factory?

The short answer

As long as you have someone keeping an eye on the security of your site, you’re just fine.  Take some time to make your decision — just don’t wait too long.

Interested in our Drupal security services?  Contact us to find out more.

The long answer

The long answer is a bit more nuanced.  When the Drupal 6 end-of-life was approaching, the Drupal Security Team asked for vendors to apply to become recognized as official Drupal 6 Long Term Service Vendors.  These LTS vendors have clients running Drupal 6 websites.  As security vulnerabilities are found and fixed in Drupal 7 (and Drupal 7 modules) the vendors are committing to make those same fixes to the Drupal 6 versions, but only for the modules that their clients are using.  

That exception has significance for other Drupal 6 sites and it all boils down to the question of:

How much security is enough?  

Low risk websites

Many (most?) websites only need to be worried about automated security attacks: Villains and mischief makers will try to attack every website on the Internet using every known vulnerability.  A tiny fraction  of the time they’ll be successful and turn a website into a spam factory, or virus spreader.  If they do their work well the site owner won’t even notice.  There’s a very low success rate, but there’s a billion websites out there.  You do the math.

High risk websites

Other websites have to worry about someone trying to actively hack their website.  There’s usually three possible reasons for this:

  • Your website has information worth stealing — Maybe your site has an e-commerce component, or a database of hundreds of thousands of membership records (with full names and e-mail addresses).
  • Your website has a lot of visitors — This is really just a subset of the first point.  If someone could infect all those visitors with a virus they could make a lot of money.
  • Someone wants to shut your website down — Maybe your organization has a political bent that some people strongly disagree with.

So what does this mean for my Drupal 6 site?

If your site is in the low risk category, then nefarious individuals will be using the vulnerabilities fixed by the LTS vendors in their automated attacks.  As long as your site continues to be updated with these fixes you are probably fine.  

There is still some risk if:

  • your site runs a module that the LTS vendors do not support,
  • and a vulnerability is found in the Drupal 7 version of that module,
  • and that vulnerability exists identically on the Drupal 6 version.

That’s possibly enough “ifs” to keep the risk at an acceptable level.

Also be aware that this support won’t last forever.  As more sites get off of Drupal 6, the LTS Vendors will have fewer clients paying for those services, and the number of supported modules will diminish.  Eventually your Drupal 6 site could be the last one standing with no one looking out for it.  How long this support is “good enough” is impossible to say.

If your site is in the high risk category, then you need to take a more active role in preventing successful attacks.  You could:

  • Move the information worth stealing somewhere else.
  • Move your site off of Drupal 6 faster.
  • Become a client of a Drupal 6 LTS Vendor to ensure that all of your modules are supported (not just the ones that other LTS Vendor clients happen to be using).

If you need help figuring out what you need, just contact us.

Photo by Billie Grace Ward

Nov 05 2013
Nov 05

Today we will look at creating a module to allow you to export your views to code. While this concept has been explored on other blogs previously, several important end steps that I find particularly useful have been left out of those discussions. I would like to remedy that here, detailing an entire process for setting up the module, displaying use scenarios, and also showing the changes that this module will make to your views administration process.

The first thing to discuss is why you would even want to export your views to code. There are a few good reasons to do this, but the most obvious one (and the one I personally find the most important) is "protection." Protection of your views and your site.

Standard views don't work until after they're saved on the site. However, since there is no such thing currently as "View Revisions," if the view ends up not functioning (or worse yet, breaks the entire site!) after saving the view, you cannot just go back to a previous version. You typically have to scrap the entire view and start from scratch. If you're just trying to make a list of content, that's not a huge deal, but if you have extremely complicated views with contextual filters, relationships, and accessing multiple parts of your site, this can at best be a headache, and at worse cost you many hours of work.

Storing your views in code allows you to have a safe place to keep a working "backup" of the view. Obviously you can just export your view and save it in a notepad file if you choose, but the method we're going to use not only backs it up, but it uses the backup as a module to display the view.

The Drupal 7 and Drupal 6 methods for this are both extremely similar. I will note the one difference below, but to be clear, this blog is speaking as though you are using Drupal 7 and Views 3.

This blog assumes you know how to create a basic custom module to use as a foundation. If you do not know how to create a basic custom module, check out our quick tutorial on the subject.

1. Hooking into views

Hooks in Drupal are just ways of modifying the website page's results.
Let's create one in our new module.

There are two hooks we will be using in this exercise: hook_views_api and hook_views_default_views. These links will take you to the drupal api pages that describe each hook.

Now let's edit the custom_example.module, and make its contents the following: <?php /* * Implementation of hook_views_api() */ function custom_example_views_api() { return array('api' => 3.0); }

This is all you need to do inside the module file. Note the api of "3.0". Here is where you will make the one change I mentioned above if you are using Drupal 6. Since Views 3.0 was never backported to Drupal 6, you will instead name "2.0" as the api. Here is the code: <?php /* * Implementation of hook_views_api() */ function custom_example_views_api() { return array('api' => 2.0); }

That's it. Now comes the fun part.

2. Providing our views

Now we will hook into 'hook_views_default_views' - basically, the purposes of this hook is to allow a module to provide views that can be read and understood by drupal. This is the main part of the blog that diverges from most other blogs on this subject. Typically, descriptions of how to export views to code end with this section, and the view is input into the hook function. However, that leaves this function very large (with a lot of view information in the function), and also makes it much more difficult to have multiple views. So the steps I will take here will be for the purpose of leaving the function clean, and providing us with a method for having as many views as you want.

Create a new file titled 'custom_example.views_default.inc' and place it in the same folder as your module. Then post the following into the file and look over the comments: <?php /** * Implements hook_views_default_views(). **/ function custom_module_views_default_views() { //Finds all files that match a given mask in a given directory //In our case, looks for any files named *.view in the /views directory $files = file_scan_directory(drupal_get_path('module', 'custom_module'). '/views', '/.view/'); foreach ($files as $filepath => $file) { require $filepath; if (isset($view)) { $views[$view->name] = $view; } } //Check that there are views in the directory //This keeps the site from throwing errors if there are no views to return if ($views) { return $views; } }

What this new hook does is it tells drupal to look into this directory that we've named (/views) and see if there are any files inside the directory using the format *.view. If there are, it takes the name of that view and sets it as the default version of that view. This will make more sense once we get a little further along, but just note that basically, this hook is telling drupal to look for your views in code.

3. Create the /views directory and start a template

Now you need to create the /views directory that is shown in the hook above. Inside your module directory, create a new folder called "views." Now create a new file and place in that directory named "view_template.view." This is an optional step, but one I find useful. Inside the template, simply paste the following: <?php //Paste Exported views Code here //Name file according to the "views_name" in exported view //Example: this_is_my_view_name.view

I use this template in a very simple way - anytime I export a new views code, I copy the exported information and paste it over my comments in the template file. Then I save-as the file with the appropriate view name.

4. An example and the "Revert" option

Let's make a quick example. You just need a list of all content on the site (note, your site already does this, but this is an example that you could literally copy from here and paste into your code and it will work, because I am using no custom cck fields, arguments, roles, etc). Open your template file created above (view_template.view), and copy the following code into the file (you can copy over the commented instructions if you like), and save the file as "all_content.view" (note that the file name is identical to value in the key-value pair on the 2nd line - $view-name = 'all_content'): $view = new view(); $view->name = 'all_content'; $view->description = ''; $view->tag = 'default'; $view->base_table = 'node'; $view->human_name = 'all_content'; $view->core = 7; $view->api_version = '3.0'; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ /* Display: Master */ $handler = $view->new_display('default', 'Master', 'default'); $handler->display->display_options['use_more_always'] = FALSE; $handler->display->display_options['access']['type'] = 'perm'; $handler->display->display_options['cache']['type'] = 'none'; $handler->display->display_options['query']['type'] = 'views_query'; $handler->display->display_options['exposed_form']['type'] = 'basic'; $handler->display->display_options['pager']['type'] = 'full'; $handler->display->display_options['style_plugin'] = 'default'; $handler->display->display_options['row_plugin'] = 'fields'; /* Field: Content: Title */ $handler->display->display_options['fields']['title']['id'] = 'title'; $handler->display->display_options['fields']['title']['table'] = 'node'; $handler->display->display_options['fields']['title']['field'] = 'title'; $handler->display->display_options['fields']['title']['label'] = ''; $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; /* Sort criterion: Content: Post date */ $handler->display->display_options['sorts']['created']['id'] = 'created'; $handler->display->display_options['sorts']['created']['table'] = 'node'; $handler->display->display_options['sorts']['created']['field'] = 'created'; $handler->display->display_options['sorts']['created']['order'] = 'DESC'; /* Filter criterion: Content: Published */ $handler->display->display_options['filters']['status']['id'] = 'status'; $handler->display->display_options['filters']['status']['table'] = 'node'; $handler->display->display_options['filters']['status']['field'] = 'status'; $handler->display->display_options['filters']['status']['value'] = 1; $handler->display->display_options['filters']['status']['group'] = 1; $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

Now here is an important step. Your new view will not show up until the views cache on your site has been cleared. In Drupal 7, go to '/admin/structure/views/settings/advanced' and click the "Clear views' cache" button. In Drupal 6, go to '/admin/build/views/tools' and click the "Clear views' cache" button. Now, when you go back to your list of views, you will see your new view. You should notice one new change as well. If you hover over the options for what you can do with that view, you will see a new option, called "Revert." It will have taken the place of the "Delete" option on any views you had the option for deleting. By clicking this button, it will delete any changes that have been made to the view on the site, and will revert the view back to its default position, which will be the view as it is in code (such is the power of the hook_views_default_view hook). This means, once you have a view that is working, you can save it to code, flush your views' cache, and then edit that view to your heart's content, knowing that if you ever mess anything up too terribly, you can always "Revert" the view back to its working glory. Or for that matter, on a production site, you can allow your clients with limited knowledge of views to attempt to create and edit their own, knowing that if something is messed up, you can easily have it fixed.

I have included two images so you can see what the view would have looked like on the views list page before flushing caches, and what it looks like afterward. Note the difference between "Delete" and "Revert":

Websmiths.co Views Tutorial - Delete Option Before Flushing Cache

Websmiths.co Views Tutorial - Delete Option After Flushing Cache

(Note: When you click "Revert," on the confirmation page that follows, it will still say "Are you sure you want to delete this view?" - this is okay, it is just the wording that was used. If on the views list page, it said "Revert" instead of "Delete," you are safe to revert.)

And that's all there is to do.

Oct 08 2013
Oct 08

Disclaimer: This post describes how to create custom pages on your drupal site, and create custom menu items (page routes), within a module. After reading this post, you will know how to implement hook_theme() and hook_menu() to create custom urls (Paths) and very basic content templates in both Drupal 6 and Drupal 7. This tutorial assumes you know how to create and upload files to your server using FTP, and also know how to create a basic custom module to use as a foundation. If you do not know how to create a basic custom module, check out our quick tutorial on the subject.

NOTE: For practice, we will be adding comments to almost all lines of code.

1. Creating a hook

Hooks in Drupal are just ways of modifying the website page's results.
Let's create one in our new module.

There are two hooks we will be using in this exercise: hook_menu and hook_theme. These links will take you to the drupal api pages that describe each hook.

New let's edit the custom_example.module, and make its contents the following: <?php /* * Implementation of hook_menu() */ function custom_example_menu(){ }

Now here is the important part about using a hook:
Copy the hook function from Drupal's API page, and replace the word hook with your module's name.
Your module is now "hook"ed into Drupal's menu system.

2. Creating a custom menu item

Edit the module file again to make its content the following: <?php /* * Implementation of hook_menu() */ function custom_example_menu(){ // path location (http://www.url.com/foo/bar ) $items['foo/bar'] = array( // page title 'title' => 'Page Title', // describe the page for the menu system. site visitors will not see this 'description' => 'Simple custom hook_menu() implementation.', // function that is called when visiting the new path 'page callback' => 'my_page_function', // permissions required to view page 'access arguments' => array('access content'), ); return $items; }

Save before continuing (always save your work!), and now let's look at what we've done here:

  • $items['foo/bar']: This key adds a new path to drupal at http://url.com/foo/bar - replace foo/bar with the preferred URL location.
  • 'title' => 'Page Title': This required key-value pair will create the page title of the menu item. Most themes implement the page title as an H1 html tag.
  • 'description' => 'Simple custom hook_menu() implementation.': This key-value pair is a short description of the purpose of this new path.
  • 'page callback' => 'my_page_function': This key-value pair is the name of the function that Drupal will call when a user is visiting the new path.
  • 'access arguments' => array('access content'): This key-value pair determines who can see the new path and content, by providing an array of specific permissions a user must have. Here is a reference page of permissions you may find useful.

If you visit the hook_menu api page, you will see that there are many more options available, but this is all we will need for this introductory tutorial.

Next, we need to create the callback function, since we named one up above. Add the following below your hook_menu function: <?php /* * Returns custom content to Drupal */ function my_page_function(){ }

We'll leave it empty for now and come back to it after the next section.

3. Creating a custom template file

We'll now create a custom template file in the module. Add the following to your custom_example.module: <?php /* * Implement hook_theme(). */ function custom_example_theme(){ return array( 'my_custom_template' => array( // file name will be custom-page.tpl.php 'template' => 'custom-page', ), ); }

We've now hooked our module into the theme system. Let's look at what these items do:

  • 'my_custom_template' => array(): This is the name of your template implementation.
  • 'template' => 'custom-page': This key-value pair will create a call to a new template file that will look like this: 'custom-page.tpl.php'. Note: You don't have to add '.tpl.php' to the value. Also, this file is not created yet, we will do that below.
  • That's it for this part, now let's look at how to make our custom page return this new template file. Edit your module again, find your my_page_function function, and alter it to look like the following: /* * Returns custom content to Drupal */ function my_page_function(){ // Call theme() function, so that Drupal includes the custom-page.tpl.php template return theme('my_custom_template'); }

    What we're doing here is telling Drupal, "When a site visitor goes to /foo/bar, include my custom template".

    Now the last thing you need to do is actually create that template. In the same directory as your module, create a new file titled 'custom-page.tpl.php'. Type the following (or anything you'd like) into it. Hello World That's pretty much it! Save the files, flush all your Drupal caches, and visit your new path. Here is what mine looks like:

    Below is a copy of the entire module file so that you can see it in it's final form. <?php /* * Implementation of hook_menu() */ function custom_example_menu(){ // path location (http://www.url.com/foo/bar ) $items['foo/bar'] = array( // page title 'title' => 'Page Title', // describe the page for the menu system. site visitors will not see this 'description' => 'Simple custom hook_menu() implementation.', // function that is called when visiting the new path 'page callback' => 'my_page_function', // permissions required to view page 'access arguments' => array('access content'), ); return $items; } /* * Returns custom content to Drupal */ function my_page_function(){ // Call theme() function, so that Drupal includes the custom-page.tpl.php template return theme('my_custom_template'); } /* * Implementation of hook_theme(). */ function custom_example_theme(){ return array( 'my_custom_template' => array( // template file name will be custom-page.tpl.php 'template' => 'custom-page', ), ); }

    That's the basics of hook_menu and hook_theme. Don't forget to enable your custom module in module administration. Good luck!

    References:

    1. Drupal 7 hook_menu API
    2. Drupal 7 hook_theme API
    3. Drupal 6 hook_menu API
    4. Drupal 6 hook_theme API
    5. A good reference post on hook_menu on drupal.org
Jun 20 2013
Jun 20

Disclaimer: This post describes how to create a custom module and use it to create custom permissions on your drupal site. The purpose is to present a general idea of how to implement hook_permission() (or hook_perm() if using drupal 6) to create custom permissions, as well as to use and find drupal hooks. This tutorial assumes you know how to create and upload files to your server using FTP.

NOTE: Though we will not need it for the purposes of this tutorial, knowledge of the usage and implementation of the devel module may be useful as you continue your exploration of custom drupal modules.

1. Creating a module

First, let's make a new module. Follow these steps exactly.

  1. Create/Upload a new folder in you drupal's sites/all/modules/ folder named custom_example
  2. Create/Upload two new files in that folder: the first named custom_example.info, and the second named custom_example.module
  3. Take a moment to notice that the module's folder name and file names are the same.

Now edit the custom_example.info file, and make it's contents the following:

name = Custom Example description = Just a simple example module version = 0.1 core = 7.x package = Alpha Custom Modules

Save/Upload that file.
Drupal 6 note: If you're doing this in drupal 6, change the 'core' number to 6.x

Next, edit the custom_example.module file and make it's contents the follow:

<?php

Thats it! Save/Upload that file and then visit your site's module page.

On your site's module page, you should now be able to see and enable the module (it's in the "Alpha Custom Modules" section). Do so.

2. Creating a hook

Hooks in drupal are just ways of modifying the website page's results.
Let's create one in our new module.

Though there are two hooks being explored in this tutorial ( hook_permission and hook_perm ), you will only need to use one of them. If your site is a drupal 7 site, you will be using hook_permission(). If your site is a drupal 6 site, you will be using hook_perm(). These links will take you to the drupal api pages that describe each hook in detail.

2.a. Using hook_permission() in Drupal 7

In drupal 7, let's edit the custom_example.module, and make its contents the following: <?php /* * Implementation of hook_permission() */ function custom_example_permission(){ }

2.b. Using hook_perm() in Drupal 6

If you are instead using drupal 6, make your module contents the following: <?php /* * Implementation of hook_perm() */ function custom_example_perm(){ }

Now here is the important part about using a hook:
Copy the hook function from drupal's API page, and replace the word hook with your module's name.
Your module is now "hook"ed into drupal's menu system.

3. Creating the custom permission

Again, if you are using drupal 7, edit the module to the following: <?php function custom_example_permission() { return array( 'administer my module' => array( 'title' => t('Administer my module'), 'description' => t('Perform administration tasks for my module.'), ), ); }

In drupal 6, it's actually much simpler code. All you need to have in your module is the following: <?php function custom_example_perm() { return array('Administer my module'); }

Save before continuing (always save your work!), and now let's look at what we've done here (Notice 2 things: 1 - In drupal 7, the strings are wrapped in the t() function; and 2 - In drupal 6, there is no description, there is simply the permission name):

  • 'title' => t('Administer my module'): This key-value pair creates the name of the permission that is displayed on your site's permission page.
  • 'description' => t('Perform administration tasks for my module.'): This simply gives a description of what the permission does.

If you visit the hook_permission api page, you will notice there are more options available in drupal 7, but those are optional, and the two above are all that is needed for this introductory tutorial. Feel free to explore those on your site and try them out, you may find them useful.

Now you will be able to call these permissions using the user_access() function. For example, if you would like to restrict access to a part of your site with this permission, you would do something like this: <?php if (user_access('Administer my module')) { // you have access! } else { // no access. }

And that's it! This is all that is required to create new custom permissions on your drupal site.

Apr 18 2013
Apr 18

It's the year 2013 and here at Cocomore we are looking forward to the future of Drupal and the release of Drupal 8.

With the release of Drupal 8 the official support for Drupal 6 ends. At the latest from this event the use of Drupal 7 should be planned. There is still some time left, but a migration does not happen during overnight. And no one wants to run a system that is not supported any more and where no security updates are available. Even http://drupal.org will soon be migrated

On February 13th 2008 Drupal 6 was published. One year later in August 2009 Cocomore started to publish its own Drupal Core because there were several problems with the official Drupal 6 core. In all these years we started to love Drupal 6 - we had 5 really good years together.

Since Drupal 7 was published we started to use it for our new projects. Recently we neglected our Drupal 6 core because we do not have many Drupal 6 sites left. So we think now it's time to say "Bye, Bye Drupal 6". We had a good time with you, but now it's time to move forward. Drupal 8 is coming. We will stop supporting Drupal 6 and we will not publish any new updates for our Drupal 6 core.

Everybody who does not want to resign the Drupal 6 core we recommend to have a look at the repository of Markus Kalkbrenner (Bio.logis) - https://github.com/mkalkbrenner/6. This Drupal 6 Core is based on the Cocomore core and contains the same modifications. So, a change without problems is possible.

We want to thank everybody who helped to work at the Drupal 6 core and even on the huge amount of modules. You have done a very great job. Thank you all!

Apr 08 2013
Apr 08
xml3d rubick

The XML3D Module provides a simple and easy way to integrate the XML3D models and applications into Drupal. The current 7.x-1.x version allows to simply enter the XML3D code into a Long Text field that has the XML3D Input Field formatter. The content will then be displayed on the page in the form of an iframe having the same size as the XML3D application.

We added this module to the blog and added a field with a XML3D example, see it at the end of this Article in action.

Requirements

The module has the following requirements:

  • Drupal 7
  • the field, field_ui, libraries modules
  • a browser with Web GL support (currently, Firefox and Chrome)
    • if you have a Intel GPU Chip and are using Chromium/Chrome on a Linux based OS, try to enable "Override software rendering list Mac, Windows, Linux, Chrome OS" under chrome://flags
  • the js library files (xml3d.js and camera.js) must be located in the corresponding folder in the libraries directory (the current version of the module uses XML3D version 4.3):
    xml3d library files structure

Adding the Field Type

After having installed and enabled the XML3D module, you must create a field of the Long Text type by going to Structure -> Content types -> Manage Fields:

xml3d add field

Then you must assign the XML3D Input Field formatter to the field by going to Structure -> Content types -> Display Fields and select it from the Format drop-down list.':

xml3d manage display

In order to add/modify your XML3D content you just need to go to your content type that contains a field with the XML3D formatter and paste the content into the field (you can grab the code from one of the examples available: http://xml3d.github.com/xml3d-examples/):

xml3d add content

The content is supposed to have one tag containing the rest of the content.

After performing all the step correctly, you should be able to see your XML3D content visualized:

xml3d rubick

As mentioned above, the XML3D element will be presented as an iframe that will have the size of the content inside (the width and height parameters of the element will be used for this). By default, the iframe has neither borders nor scrolling. That can easily be changed via the CSS file in the module ([modules folder]/xml3d/css/xml3d.css). The iframe has a class named "xml3d_frame" that you can use for styling it.

Global Integration into Drupal

While working on the module we met some obstacles. The major obstacle was the requirement to use the MIME-type application/xhtml+xml for the pages that have XML3D content. Moreover, the page must start with:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">

The problem is that a standard page in Drupal is not of application/xhtml+xml type and it has the following header (doctype) element:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>

The header is hard coded in the html template file (modules/system/html.tpl.php) and is not/or hardly editable from within a module (it could be overridden by a theme, though). Thus, the first attempt to set the MIME type with php and change the header in the template file manually failed (it worked in Chrome only).

The second attempt to build in an iframe and put the content using JavaScript on the fly failed as well. It worked neither in Chrome nor in Firefox. Different techniques have been used here: starting from contentDocument.open('') (or contentWindow.document) with different MIME types including 'application/xhtml+xml' and finishing with '...src="http://drupal.cocomore.com/blog/xml3d-and-drupal/data:application/xhtml+xml...."'.

At the end, an iframe referring to a separate page (generating the content for a certain field) was decided to be used. The page must receive four arguments: entity type, entity id, field name and delta. For example: http://example.com/xml3d/iframe/node/18/field_testxml3d/0

To Do

The current version of the module is aimed to present a simple integration of the XML3D technology into Drupal. Thus, the content to be inserted is not supposed to be very long.

As an alternative option to the currently implemented variant could be uploading a file (or files) with the content to be inserted or selecting from a predefined list of content residing on the same or a third-party server. It would make the integration process of large pieces of code easier for the end user.

Example:

Mar 30 2013
Mar 30

At the Boston Drupal meetup that was at Acquia this month, several presentations were focused on “what’s new in Drupal 8” from the view of several people who now work at Acquia. I loved it. There were other presentations, as well (including one of my own!), and I really enjoyed seeing the Boston Drupal group again after many months.

During the questions and answers part of the meetup, I asked Dries if he was considering naming a security maintainer for Drupal 6 when Drupal 8 is released. (In case you didn’t know, support for Drupal 6 will be discontinued by the Drupal core and security teams. See the handbook page on backwards compatibility at https://drupal.org/node/65922 for more, including Dries’ original statement on the subject in 2006.)

read more

Mar 06 2013
Mar 06

There are some times in Drupal 6 where you push the limits of what the blocks interface can do. If you need to display the same block, multiple times on the same page, you will start to see these limitations. An example of where this is useful is a Newsletter signup form. Sometimes a client may want a newsletter signup form to be in the footer of every page, but also displayed more prominently on the contact form page.

You will also run into this issue if you want to output a block in one region on one page and another region on a separate page. An example of this would be to display the newsletter signup form in the header on the front page, but in the footer on every other page of the site.

Both of these examples can easily be achieved using something like Panels or Display Suite, but if you want to stick to the blocks interface, here is a simple way you can solve this by building a custom Drupal 6 module.

The first step is to create a simple Drupal 6 module. After you have the module created, we need to create our own Drupal 6 block. Drop the following code in your .module file. You will need to replace the module name with the name of your module. You will also need to look through the other code replacing text and descriptions as necessary. In my example I will be going through creating a second block for the Drupal 6 Constant Contact module.

/**
 * Implements hook_block().
 */
function MYMODULE_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks[0] = array('info' => t('Constant Contact Block 2'));
 
    return $blocks;
  }
  else if ($op == 'view') {
    switch ($delta) {
      case 0:
        // Your module will need to define this function to render the block.
        $block = array(
          'subject' => t('Title of block #1'), 
          'content' => '',
        );
        break;
    }
    return $block;
  }
}

The next step is to identify the block you want to display. The best way to do this is to figure out which module you need to duplicate the block for. In my example this was the Constant Contact module. Open up the .module file for whichever module you want to duplicate the block for.

Once you have the module file opened, do a search for "_block" or "hook_block". This should get us to the function that has all the details you need to insert the line of code that will print this block. We need to get the module name and the delta value for our block. Here is an example from the constant_contact.module file's hook_block implementation.

/**
 * Enables us to place a signup form into a block
 */
function constant_contact_block($op = 'view', $delta = 0, $edit = array())
{
	switch($op) {
		case 'list':
			$blocks[0] = array(
				'info' => t('Constant Contact Signup Form'),
				'visibility'      => 0,
				'roles'      => array(1),
				'pages'      => 'user*',
			);
		return $blocks;
		case 'configure':
			$form = array();
		return;
		case 'save':
		return;
		case 'view':
			switch ($delta) {
				case 0:
					$block['subject'] = t('Signup');
					$block['content'] = drupal_get_form('constant_contact_signup_form');
				break;
			}
		return $block;
	}
}

I can pull out the module name from the function constant_contact_block and get that "constant_contact" is the module name. You can also take this from whatever is in front of the .module in the constant_contact.module file name.

The next step is to pull out the delta value for the block. This is displayed below the switch ($delta) { line of code. In this "case" we want the number "0". This is pulled from the case 0: line of code. Blocks may have multiple of these case statements, you will need to find the right delta value for the block you want to display. Many times in a Drupal 6 hook_block implementation this will simply be 0.

We now add the following line of code to our modules hook_block function.

$block = module_invoke('MYMODULE', 'block', 'view', [DELTA]);

We replace MyMODULE with the module name, in this case "constant_contact" and we replace [DELTA] with the delta value, in this case 0. Here is what the finished line of code looks like:

$block = module_invoke('constant_contact', 'block', 'view', 0);

You then need to replace this line of code with what would normally be your Drupal 6 block output code. The final version of your Drupal block code should look something like this:

/**
 * Implements hook_block().
 */
function MYMODULE_tweaks_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks[0] = array('info' => t('Constant Contact Block 2'));
 
    return $blocks;
  }
  else if ($op == 'view') {
    switch ($delta) {
      case 0:
        $block = module_invoke('constant_contact', 'block', 'view', 0);
        break;
    }
    return $block;
  }
}

You can now add this block just like you would any other block. It should be an exact duplicate of the other Drupal block.

A couple notes: This approach still has it's limitations so a better solution is using something like Panels or Display Suite. However it works well for one off simple fixes on sites that are already making heavy use of blocks. Also note that if you are displaying the same block multiple times on the same page, everything should work fine, but your CSS may not validate if the block uses the same CSS ID since it will now be in multiple places inside the HTML.

Hope that helps and let me know if you have any questions.

Mar 03 2013
Mar 03
Modules of the month story banner illustration.

Well, February is always a short month, but this year it seemed like it passed in just a couple of weeks… and now it’s already March and I’m only finally getting around to putting the final touches on this posting for the January “Modules of the Month”. How did that happen? Well, I won’t try to bore you or make excuses. It’s just been one of those months. I’m going to try to keep up my current momentum and evaluate and write up my favorites from February now… hopefully finishing that in the next week or so. If it’s not done by the 15th, it won’t be done till April since I’ll be taking off for my first trip to India in the middle of this month.

But I’m not here to write about myself. This is about some modules which I found might be worthy of notice… specifically those released in January 2013. It’s interesting to see the evolution of a Drupal version and what kinds of modules are being released these days. Almost no modules are being released for Drupal 6 and Drupal 8’s developer API is still far enough from maturity that there are very few modules being released for it, so almost all the focus is on Drupal 7. Almost anything really critical has already been done, so most modules now fit into areas of workflow improvement, integration of third-party libraries, developer tools, and addressing the needs of an increasingly mobile audience (responsive design). There are a lot of new modules for image display, for keeping a closer eye on site administration issues, creating better e-shops, deploying content from one site to another, and managing caching, among other trends. It’s clear that Drupal 7 is a mature product serving the needs of an extremely diverse community and it’s exciting to see all the new ways that, each month, developers encounter new needs and find inventive ways to further extend on the feature-set. So read on to see what new and fun stuff we got in January… (and I promise to try to get February’s review done in the next week or so).

*/ Access denied backtrace

The Access denied backtrace module helps track down the point where access rights are denied.How many times have you had to try to sort out access issues on a Drupal site? Sometimes this can be a pain, but the module, by Eduardo Garcia of Anexus IT, promises to help put an end to this senseless suffering; it helps track down the exact point at which a particular role is denied access for a particular node or path. Perhaps the screenshot here is a bit contrived; the only reason the basic "authenticated user" cannot create a new node of type "Article" is that they don’t have the appropriate permission checked. In a more complex site with lots of custom content and custom user-access code, this could be very useful. (My primary work is on a team where the access model for all content types and users would require a full article to explain.)

Status: There is a stable release available for Drupal 7.

Advanced help dialog

The module, by Dan Polant of Commerce Guys, allows developers to extend the popular Advanced Help module. By implementing the provided hook, you can add a link to the "Help" region of specific paths; the link opens a modal box with the relevant "advanced help" content. Nice.

Status: There is a development release available for Drupal 7.

Anonymous Redirect

The module, from Michael Strelan of Glo Digital, redirects anonymous users to another domain, but visitors can still reach /user or /user/login to authenticate. After logging in, users have normal access. This can easily be configured to limit access to a staging server and redirect users to your production site, the most typical use case for the module.

Status: There is a development release available for Drupal 7.

Boost Custom Expire Rules

The module, authored by Zyxware Technologies, allows setting different expiry times for content cached with Boost. Complex rules can be configured to fine-tune how long various content on your site is cached. Older nodes can have a longer cache lifetime, for instance. Rules can be configured for the URL path, node type, age, etc. This definitely looks like a must-have for sites which use Boost, especially if they actively add new content on a regular basis and retain older content.

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Block Up Down

The Block Up/Down module allows you to easily disable or move blocks within a region without going into block administration.The module, coded by Pol Dell'Aiera of Trasys, is dead simple. Just activate it and you get three new contextual links on blocks so you don’t need to go into the block administration page just to disable a block or move it up or down within a region. I think this is great, since probably most of the time I go into the block administration page, which can take a while to load on a complex site with a lot of blocks and regions, moving one block up or down (or disabling a block) is all I really want to do, so allowing administrators to manage this from within the front-end is a really sweet feature.

Status: There is a stable release available for Drupal 7.

CKEditor Link File

The CKEditor Link File module, created by Devin Carlson, integrates (and requires) the CKEditor Link and File entity modules so that editors on your site can easily add links to existing files on your site. This definitely looks useful for sites which use CKEditor.

Status: There is a stable release available for Drupal 7.

Combined Termref

The module, written by Girish Nair, allows you to address up to three different vocabularies with one term-reference field; obviously only one vocabulary in the group can take “free tagging”. If new terms are added, they go into the first of the vocabularies selected for the Combined Termref field. There can be good reasons that you need different vocabularies, but the purpose can stay behind the scenes; content creation can be simpler by allowing entry with a single field. I think this looks cool.

Status: There is a beta release available for Drupal 7.

Commerce Cart Message

The Drupal Commerce Cart Message module displays a message in the cart.The module, authored by Aidan Lister, provides an option to add rules for displaying messages on your Drupal Commerce cart. This definitely looks useful.

Status: There is a stable release available for Drupal 7.

Views Contextual Range Filter

The module, written by Rik de Boer of flink, provides a Views plugin that allows you to filter views based on a range of values for any field where this might make sense. For instance, you might want to filter by price range, age range, etc. This kind of search is a pretty common use case, so I suspect this will become quite popular.

Status: There is a stable release available for Drupal 7.

Creative commons field

The module, by Ben Scott, defines a field type for attaching Creative Commons licence types, so you can add CC licences to files or any entity type. There are other modules which can add a CC license, but they only work with nodes; files are likely a most common use case. Cool!

Status: There is a stable release available for Drupal 7.

Entity Extras

Categories: Utility

The module, coded by Dave Hall, provides extra utility functions to extend the Entity API module. The idea is to share useful functions here and improve on them before proposing them for inclusion in Entity API or Drupal core. If you aren’t a developer, you’ll probably only enable this if another module requires it, but if you write your own modules which use the Entity API, this is probably worth taking a look at.

Status: There is an alpha release available for Drupal 7.

Facebook Album Fetcher

The module, written by Kaushal Kishore of OSSCube, allows you to import your Facebook albums and photo galleries. You can also import the images from your friends’ accounts, too, but be sure you ask your friends if it’s okay. Personally, I only allow friends to view my Facebook account, so people like me might be annoyed if the images they shared on Facebook were pulled into a public-facing album without their consent. That said, companies with a Facebook presence might like to pull the images from their Facebook galleries into a gallery on their main website, and I’m sure there are many other good use cases for this module.

Status: There is a stable release available for Drupal 7.

Field Collection Deploy

The module, created by Robert Castelo of Code Positive, provides a way to deploy content from the Field Collection fields from one site to another. It extends (and requires) Features, Field Collection (of course), UUID, Node Export, and Entity API. Getting this to work is clearly non-trivial, but if you need this functionality, you’ll be happy to find this module.

Status: There is a beta release available for Drupal 7.

File Entity Preview

Categories: Media

The module, contributed by Graham Bates of Catch Digital, provides a widget for file fields with previews of uploaded files, as configured with File Entity. It otherwise works like the “core” File widget.

Status: There is a stable release available for Drupal 7.

Graphviz

The module, written by Clemens Tolboom, renders a Graphviz text file for further processing; it hooks into Graph API to provide Views integration and can output an image file using the Graphviz Filter.

Status: There is a development release available for Drupal 7.

Graph Phyz

Graph Phyz helps display a nice relationships graph. is another graph-related module contributed by Clemens Tolboom. It renders an interactive graph using Graph API. Pretty cool, if your site calls for this, and I can think of at least one project where this might have saved some custom coding.

Status: There is a development release available for Drupal 7.

Hide PHP Fatal Error

The module, by B-Prod of MaPS System, redirects users to a configurable error page whenever a fatal error is thrown in PHP. Of course the error is also logged into the watchdog so you can work on eliminating the error for the next user. Nice.

Status: There is a stable release available for Drupal 7.

Hierarchical taxonomy

The module, by Marcus Deglos of Techito, is a developer module (you won’t need this, as a non-coder unless another module requires it) which provides a simple hierarchical_taxonomy_get_tree() function which renders an array of a vocabulary’s hierarchical structure. This should probably be in “core”.

Status: There is a development release available for Drupal 7.

Image Zoomer

The Image Zoomer module integrates various Javascript libraries for getting a closer look at an photo.The module, contributed by Tuan, integrates two image zoom-related JQuery plugins; Power Zoomer and Featured Zoomer and the developer of this module is adding support for other modules which provide image zooming. This could be cool for online “catalog” images or for commercial photography sites who want to provide a closer look at an image without making it too simple for users to download a higher-resolution version.

Status: There is a stable release available for Drupal 7.

Image Focus Crop

The module, contributed by Nguyễn Hải Nam of Open Web Solutions, helps find the focal center of an image you are scaling and cropping and includes advanced facial recognition algorithms. This looks interesting.

Status: There is a stable release available for Drupal 7.

Image formatter link to image style

image_formatter_link_to_image_style.pngThe module, developed by Manuel García, provides an additional formatter for the core image field so that you can create, for instance, a “thumbnail” which links to a larger, watermarked version of the image. This seems like a common enough need that this kind of functionality should probably be added to core. Until then, there’s this.

Status: There is a stable release available for Drupal 7.

jQuery UI Slider Field

The Jquery Ui Slider Field module provides a simple way “slide” between a range of integer values.The module, developed by Sina Salek integrates the jQuery UI Slider plugin so you can easily allow users of your site to utilize a graphical slider to quickly enter an integer value in a field. This looks handy, especially for users accessing your site without a normal keyboard.

Status: There is an alpha release available for Drupal 7.

Juicebox HTML5 Responsive Image Galleries

The Juicebox integration module for Drupal helps you display a beautiful responsive image gallery.The module, written by Ryan Jacobs integrates the beautiful Juicebox HTML5 responsive gallery library into your Drupal site. There’s a lot to this module; probably enough to have a whole article dedicated to ways you can use it, but it definitely looks nice if you want to provide image galleries that render well on a wide range of devices. Like many other such modules that integrate third-party code, it requires Libraries and adding the Juicebox code to your sites/all/libraries directory. We should note that there are both Lite (free) and Pro (commercial) versions of Juicebox (you’ll need to decide which is more appropriate for your use case) and the maintainers of this module are not affiliated with the developers of Juicebox, itself. This module will work to integrate either version of Juicebox.

Status: There is a beta release available for Drupal 7.

Lazy Entity

The module, written by James I. Armes of AllPlayers.com, allows field values for Drupal entities to be lazy-loaded rather than loaded at the time the entity loads, so can provide a boost to performance and memory usage. This module is for developers, so will not be useful to you unless you are a coder who needs to lazy-load fields. Otherwise you would only enable this module if another module requires it.

Status: There is a development release available for Drupal 7.

Linked Data Tools

The module, by Chris Skene of PreviousNext, is a developer module to help retrieve, cache, and work with linked data sources. It depends on EasyRDF and X Autoload and Guzzle is also recommended.

Status: There is an alpha release available for Drupal 7.

Library attach

The module, written by Dave Reid of Palantir.net, adds a Library reference field type so that libraries can be attached to individual entities when rendered, thus saving your site from loading lots of unnecessary Javascript for every page. It also adds an option to the Views UI so allows adding libraries for specific Views displays. This is a great idea!

Status: There is an RC release available for Drupal 7.

Lorempixel

The module, written by Fredric Bergström of Wunderkraut, provides “dummy images” which it fetches from the very slick lorempixel.com web service. Oh, and the module can also be used to get the placeholder images added to content by Devel generate.

Status: There is a development release available for Drupal 7.

MD WordCloud

The MD Wordcloud displays a cloud of all terms in a vocabulary, sized according to frequency of their use.The module, written by Neo Khuat, creates a block with a “cloud” of terms from a taxonomy. You’ll need to download and add some Javascript files to the module’s “js” folder. So you don’t need to save and replace the Javascript files, it might be better to symlink them to a directory in sites/all/libraries.

Status: There is a stable release available for Drupal 7.

Multisite wizard

The module, written by Alex Posidelov, helps simplify the process of converting a single site Drupal installation to multisite. A lot of the work is done for you with just one click of a button and it helps lead the administrator through the rest of the requirements. It depends on the Backup and Migrate module.

Status: There is a stable release available for Drupal 7.

Notify 404

, by teknic of Appnovation Technologies, provides a means to send notification emails to a site administrator when a configurable volume or frequency of 404 (page not found) errors have occurred.

Status: There is a stable release available for Drupal 7.

Photobox

The Photobox module integrates the jQuery-powered Photo-box gallery as a display format for images.The module, developed by Andrew Berezovsky of Axel Springer Russia, adds an Image field formatter for viewing images in a Photobox image gallery. You’ll need to use the jQuery Update module since Photobox requires jQuery 1.8. This does look nice.

Status: There is a development release available for Drupal 7.

RecommenderGhost

The Recommenderghost module integrates the free external recommender service to help show users other content of interest on your site.The module, coded by hhhc, integrates the free recommender services hosted by RecommenderGhost. It makes it easy to display recommendations for “other visitors bought…”, etc. This is much simpler than installing and integrating a separate server.

Status: There is a stable release available for Drupal 7.

Reference helper

Categories: Fields

The module, created by Kevin Miller of Cal State Monterey Bay, is a helper module for displaying recent or most relevant entities under an entity reference field and was a winner of the Module Off challenge. It definitely sounds useful.

Status: There is a development release available for Drupal 7.

Regcheck

The module, produced by Tobias Haugen of Wunderkraut, adds a hidden checkbox to your site’s registration form; if checked, the registration process is aborted. “Robot” users tend to check the box, so it can be a simple way to eliminate at least some of the unwanted registrations used for spamming your site or other nefarious purposes. There are other modules which help with protecting forms like this, but a wide variety of spam prevention methods are useful for keeping a step ahead of the bot coders.

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Simple hierarchical select

The module, written by Stefan Borchert of undpaul, defines a new form widget for hierarchical taxonomy fields so you can simply navigate the structure of the taxonomy and select a term.

Status: There is a stable release available for Drupal 7.

Site Disclaimer

The module, by Ilya I, can add “Terms of Use”, “Privacy policy” or other agreements to the registration form. Visitors who want to register on your site need to agree to the terms of the “disclaimer” in order to register.

Status: There is a stable stable release available for Drupal 7.

Tablesorter

The Tablesorter module integrates a jQuery plugin to allow standard tables to be sorted by any column.The module, coded by Shoaib Rehman Mirza of Xululabs, integrates the tablesorter jQuery plugin so that any standard HTML table with THEAD and TBODY tags can be turned into a sortable table without even requiring a page refresh. Of course it’s not helpful if the data is paginated, but for normal tables with all the data on one page, this could be useful. Of course you need to download the Javascript libraries and install them in your sites/all/libraries directory, and of course that means this depends on Libraries API.

Status: There is a stable release available for Drupal 7.

Taxonomy Protect

The Taxonomy Protect helps prevent users with some administration rights from deleting vocabularies.The module, contributed by Jay Beaton allows administrators to select certain taxonomy vocabularies and prevent them from being deleted. That way, even if some users who need to be able to administer taxonomies don’t fully understand the system, they won’t make the mistake of deleting a critical vocabulary.

Status: There is a stable release available for Drupal 7.

Topbar Messages

The module, created by Mark Koester of Int3c.com: International Cross-Cultural Consulting, allows you to add a message in the top of your Drupal pages. The message can be dismissed with a click on a “close” link and can include links and other formatting. There are other such modules, but this one might be the best fit for your use case. It does look useful.

Status: There is a development release available for Drupal 7.

Views Ajax Fade

The module, authored by Thomas Lattimore of Classic Graphics, is a Views plugin which allows you to add a fade in/out effect for Ajax-enabled Views displays. This would be nice for some use cases.

Status: There is a stable release available for Drupal 7.

Webform Countdown

Categories: Content

The module, by Andrew Lindsay provides a textarea component for Drupal webforms which includes a configurable, Twitter-style dynamic word or character count to limit the length of submissions. Of course it requires the Webformmodule and Libraries module (as well as the word-and-character-counter.js in sites/all/libraries.

Status: There is a beta release available for Drupal 7.

Webform Postal Code

Categories: Content

The module, is another Webform-enhancing module contributed by Andrew Lindsay. It adds strong, configurable postal code validation which can even be set to handle multiple countries simultaneously. In addition to the obvious dependency on Webform, this also requires the Postal Code Validation module.

Status: There is a beta release available for Drupal 7.

Feb 02 2013
Feb 02

Episode Number: 

100

The big 100th episode! In this episode I go over my company's Drupal development environment (http://beginr.com). I discuss how we use Aegir (http://www.aegirproject.org/) to manage and deploy our Drupal websites. I also mention how the development process works using development and live environments spread across multiple servers dedicated to hosting Drupal websites. I mention what operating systems we use along with my person preference for browsers.

One thing I didn't mention is that I use Komodo Edit for my code editor. I think it is pretty awesome.

I also mention sponsorship opportunities, so if you want to become a sponsor of the Daily Dose of Drupal, here is some more information - http://codekarate.com/content/become-codekarate-sponsor

DDoD Video: 

Jan 16 2013
Jan 16
A new Drupal module: Biblio autocomplete.

Previsoulsy as part of eMonocot we started to use the IPNI webservice to autocomplete some fields in the Biblio content type. As one of the eMonocot objectives is to "Ensure that the tools developed are compliant with zoological nomenclature" I have extended this functionality to use the ZooBank API which is currently in a testing phase. In addition values for the autocomplete suggestions can be made from values previous entered in other Biblio nodes.

Instead of having either previsously entered values, IPNI or ZooBank attempt to autocomplete the field this module has been developed to allow any combination of these plugins to attempt the autocompletion. This will have uses in cases like the recent Lyme Regis Geo-BioBlitz where a single classification spand both animal and plant kingdoms (in this case the Dictioanry of UK Species).

The module is designed so that additional plugin modules can easily contribute results for other webservices.

This work was done as part of eMonocot as a contribution to the Scratchpads project.

Jan 02 2013
Jan 02
Modules of the month story banner illustration.

Closing out the year 2012 with a bang, December brought us quite a number of new modules which look promising enough to cover; a few that I’m covering this time are far from ready or even only at the “concept” stage and normally would not be included, but they seemed particularly interesting or unique, and I want to see how they develop. Anyway, this month there were quite a few modules released for mobile support/responsive content. There were also several search-related modules, anti-spam modules, a couple of novelty modules, some interesting commerce-related releases, a number of Features package modules customized for various special-purpose distributions, lots of new “Third-party Integration” modules, theme enhancements, and more… I only wish I had more time so I could actually try out more of them, but there are several I do plan to get back to.

As usual, this post is sorted alphabetically and only covers modules which had their first release, or at least a new project created, in December. Selection for the Modules of the Month is a completely arbitrary process, but normally excludes common or niche items like a new payment method for Commerce that provides connections for a payment system used in, e.g. Romania. We also don’t normally include commercial service integration modules (unless the service looks really cool and is reasonably priced).

Anyway, it seems like only last week that I was putting the final touches on the November “Modules of the Month” story… oh wait, it was only last week: nine days ago, as I write this. Well I promised to try to get December’s published in early January, so I pushed some days around to make this happen. Let’s take a look at the modules, then, shall we? …

*/ Activation Code

The module, brought to us by prolific über-contributor Bryan Ollendyke of Penn State University, provides a fieldable “activation_code” entity type with a number of fields for an ID, creation timestamp, redemption timestamp, username, etc. It’s used by the Course Information System distribution as another method for authorizing access to online course materials, etc, but for those who don’t need the module on their site, it could still provide a useful example for how to build a fieldable entity.

Status: There is a development release available for Drupal 7.

Apachesolr Link

Categories: Search

The module, produced by Michael Prasuhn of Shomeya, enables indexing a Link field’s “target”, along with the entity it is attached to, in the Apache Solr search index. It might be obvious, but this module depends on Link and Apache Solr Search Integration; the Apache Solr Attachments module will also be useful if some of the links you wish to index are to PDF files or other “non-plain-text” results which you wish to index.

Status: There is a development release available for Drupal 7.

Are You A Human PlayThru Are You a Human Playthru login

The module, written by Chris Keller of Commercial Progression, provides a more simple, fun, and intuitive means for a user to prove they are human than typical CAPTCHA options. It uses game mechanics which a user interacts with rather than having users try to interpret text in graphics. CAPTCHA fields can be frustratingly and tedious, so it’s nice to see people are working on interesting alternatives. Cool! I often skip over commercial third-party integration modules, but this seems interesting enough not to pass up, and they do provide free options which might be adequate for many sites.

Status: There is a beta release available for Drupal 7.

Backstretch Formatter

The module, written by Yannick Leyendecker of LOOM GmbH, provides a field formatter for jQuery Backstretch - A simple jQuery plugin that allows you to add a dynamically-resized, slideshow-capable background image to any page or element. Once you have everything (JavaScript libraries and the module, etc) correctly installed, if you select “Backstretch” as field formatter for an image field which allows more than one image you will get a slideshow. If your slideshow needs don’t require anything too fancy, this could be the ideal module to implement it. Cool!

Status: There is a development release available for Drupal 7.

Badbot

Because we wouldn’t want one CAPTCHA alternative to be lonely… the module, developed by Yuriy Babenko of Suite101, provides another method of CAPTCHA-free spam-prevention; it is currently limited to the user registration form, but comment forms are in the works. Visitors must have JavaScript enabled in their browsers for this system to work; it displays an error if JavaScript is disabled. Since spam bots generally do not parse JS, this helps avoid the need for CAPTCHAs, which are often solved by low-paid workers these days, anyway.

Status: There is a stable release available for Drupal 7.

BetterTip

The module, produced by Shoaib Rehman Mirza of Xululabs, is a lightweight jQuery plugin for clean, HTML5-valid tooltips which can provide a richer user experience than default tooltip text.

Status: There is a stable release available for Drupal 7 (and the project page includes a pledge to provide a Drupal 6 version).

Breakpoint Panels

The module, developed by Daniel Linn of Metal Toad Media, adds a Panel style called “Breakpoint Panel”. When selected, it will display checkboxes next to all of the breakpoints specified in that module’s UI. Unchecking any of these will “hide” it from that breakpoint. If you are lost by this description of the functionality, it probably helps to understand that “breakpoints” define different display-width ranges so that you can determine layout for content on different width devices or even eliminate some content from being displayed on, e.g. devices less than 480 pixels wide. Of course it depends on the Breakpoints module, whose functionality is going into Drupal 8 “core”, and Panels, but you’ll also need to download some Javascript files and enable them with Libraries. See the project page for further details, but this could definitely help improve mobile/responsive content and the roadmap looks good, too.

Status: There is a stable release available for Drupal 7.

Christmas Lights

The module, created by Andrew Podlubnyj, is, depending on your use case, of course, probably just a novelty module, but one that might be fun to enable in the right season. It adds decorative “Christmas lights” for you and your users to enjoy.

Status: There is a stable release available for Drupal 7.

CKEditor for WYSIWYG Module

When Nathan Haug of Lullabot-fame releases a new module, it’s always GoodStuff™, so it’s no surprise that there are already hundreds of sites using the after just one month. It provides a WYSIWYG editor (surprise, surprise!) using the CKEditor library (surprise, again!). This project aims to combine some of the best of the Wysiwyg-module integration with CKEditor with the best of the standalone CKEditor-integration module, with support for the Drupal Image and Drupal Image captioning plugins, compatibility with other WYSIWYG editors integrated through the Wysiwyg module, and no inline styles inserted into HTML… among other nice features either already implemented or in the “roadmap”. It requires the Wysiwyg module and is incompatible with the normal CKEditor integration module (which must be completely removed before using this module).

Status: There is a development release available for Drupal 7.

Coins wallet

The module, authored by ssm2017 Binder, is a Bitcoin wallet system to be used with a devcoin-compatible daemon. This module is a complete rewrite for Drupal 7 of the never-released original Drupal 6 version discussed here and uses the bitcoin-php library. While I confess that I’m a bit leery of how this all works, I’m also fascinated by the idea of alternative currencies which aren’t controlled and manipulated by bankers and other “white collar criminals”, so while the optimist in me is curious to see how this works, the pessimist in me worries that between human greed and governmental attempts to rein this in, well… interesting work, in any case.

Status: There is a stable release available for Drupal 7.

Collapsible fieldset memory

The module, written by David Herminghaus, solves a nice little UX issue for Drupal. If you have ever worked on a project where you had to enter content into Drupal forms with fieldsets which needed to be uncollapsed to access required fields, or where closing fieldsets to get them out of your way is part of your workflow, you might like this module. It allows everyone, even anonymous users, to have stored defaults for any Drupal form with collapsible fieldsets, so if a fieldset on a form was uncollapsed when you last used it, it will start out that way the next time you do. Nice! Of course it requires Javascript (as do collapsible fieldsets). The developer is open to feature requests and issues, so pitch in if you use this module and help make it better. There’s a bit you should know about before implementing it on your site, so be sure to peruse the project page.

Status: There are alpha releases available for both Drupal 6 and Drupal 7.

Commerce Check

Status: There is an alpha release available for Drupal 7.

Commerce Message

The module, produced by Bojan Živanović of Commerce Guys, provides Commerce-specific Message integration, including some default message settings for common order states, such as “order paid”, “product added to cart”, “order confirmation”, etc. It looks like a pretty well-thought-out module to help provide automated or custom messages to clients at appropriate stages in their order process. It’s integrated with Commerce Backoffice and Commerce Kickstart v2, so is already in use on quite a number of sites.

Status: There is a beta release available for Drupal 7.

Commons Polls

The module, by Ezra Barnett Gildesgame of Acquia, and the primary maintainer of Drupal Commons, integrates Drupal’s “core” Poll module as a group-enabled content type in Drupal Commons 3.0.

Status: There is a development release available for Drupal 7.

Content callback If you register a content callback via hook_content_callback_info() it will be available in the Content callback field options.

—Project description excerpt

The module, developed by Jasper Knops of Nascom, allows you to return any renderable array, created in code, via a field; it also contains a sub-module which provides a searchable Views display, as well as a context condition, among other features you should check out on the project page. If it’s not clear, though, I might mention this is not a simple add-and-enable module; it provides some tools for coders and advanced site builders.

Status: There is a stable release available for Drupal 7.

Context Breakpoint

The module, developed by Christoph, helps bridge Context and Breakpoints so that you can alter a page based on the visitor’s screen resolution, browser window size, or aspect ratio. Installing it adds a context condition for “Breakpoint”. This could definitely be useful, especially if your site already uses Context. Of course it’s a bit complex, so please see the project page and the module’s README file for information about how to install, configure, and make use of this.

Status: There is an alpha release available for Drupal 7.

Context code

The is another module by Jasper Knops of Nascom. It provides “a new context condition plugin which allows you to trigger contexts from code”. It should probably go without saying that it requires the Context module and is a module developed for other developers. See the project page for implementation examples, but I think this looks very useful, at least for advanced Drupalists and coders.

Status: There is a stable release available for Drupal 7.

CP2P2: Content Profile to Profile2

The module, written by Damien McKenna of Mediacurrent, is an add-on for Profile2 to convert Content Profile content types into Profile types. Note that there is no admin user interface for this; all functionality is provided by Drush commands run in the terminal, so this module is targeted toward experienced Drupalists and coders.

Status: There is a beta release available for Drupal 7.

Create and continue

The module, written by Dominique De Cooman of Ausy/DataFlow, simply adds a button to node forms which saves the current node and opens node/add/CONTENT_TYPE to create another instance of the same node type and help streamline the content creation process.

Status: There is a stable release available for Drupal 7.

Crossdomain

Categories: Media

The module, written by Adam Moore of Stanford Graduate School of Business, simply creates a crossdomain.xml file at the root of your Drupal site and provides configuration setting for which domains should be included. This is useful for certain web services which may require different domains to have access to your site content.

Status: There is a stable release available for Drupal 7.

Currency for Drupal Commerce

The module, produced by Bart Feenstra replaces the native currency-based price display in Drupal Commerce with locale-based display, using the Currency module. Because proper display depends on locale (language and country) and not on currencies, this module helps ensure that users see prices in a format they are used to.

Status: There is a beta release available for Drupal 7.

Field Quick Required

The module, written by Jelle Sebreghts of attiks, provides a simple overview of which field are required for a given content type, without having to enter the settings for that field. You can also change the “required” setting for any field. Nice! It does this by adding an extra column to the “manage fields” overview for your content types, e.g. for /admin/structure/types/manage/article/fields, where you would normally have columns for “Label”, “Machine name”, “Field type”, “Widget”, and “Operations”, you would also have a column labeled “Required” with a checkbox that can easily be changed if you decide a certain field should (or should not) be required for a particular content type. This could be especially useful during the initial phases of designing a site’s content types and logic.

Status: There is a stable release available for Drupal 7.

"File Metadata Table" Field Formatter

Categories: Fields

The module, written by Jeremy Thorson, with support from Derek Wright, looks interesting. It’s still in development, but it provides a customizable “File Metadata Table” field formatter for file fields. All of the options are a bit much to list here, but given the profiles of these two super-contributors, I think this will be an interesting module to check back on. I’m expecting something awesome here!

Status: There is a development release available for Drupal 7.

Foresight Images

The module, developed by Graham Bates of Catch Digital, provides a field formatter which integrates the foresight.js library to display image fields. Images are requested and generated at the exact size required. As with other such third-party Javascript library integrations, this will require Libraries and you install the additional JavaScript code in sites/all/libraries. I’m not convinced that this module offers enough benefits to select it rather than one of the other more-established responsive image modules; I’m also not convinced otherwise and the Foresight Images project page includes a list of other “similar” responsive images modules and some brief notes about how the approach or features differ from those provided by Foresight Images. So this project page could be worth looking at if you need an overview to help choose the appropriate module(s) or approach for your next project.

Status: There is a stable release available for Drupal 7.

Forum notifications

The module, created by David Snopek, extends the Notifications module to add some nice UI improvements for notifications involving forums based on the “core” Forums module. If you have a site with forums and wish to have a nice user experience for “subscribing” (and “unsubscribing”) to forums or individual threads, this module could help.

Status: There is a development release available for Drupal 7 and a beta release available for Drupal 6.

htaccess

The module, coded by giorgio79, autogenerates a Drupal root htaccess file based on your settings, including such configuration settings as automatic insertion of Boost htaccess settings, whether or not to use “www”, Followsymlinks or SymlinksIfOwnersMatch, etc. You simply configure these settings at /admin/config/system/htaccess if this module is enabled and of course you could only enable this module when upgrading Drupal, to replace the default .htaccess with one based on your settings. I don’t think it should be so dangerous to try this, but you might want to make your own backup copy of your current .htaccess file, just in case anything goes wrong (in theory, this module should also make a backup copy of your existing .htaccess file).

Status: There is a stable release available for Drupal 7.

Image optimize effect

The module, yet another contributed by Peter Droogmans of Attiks, adds two new image effects to optimize image files to reduce your average page size. Most websites do not have very well optimized images and images can be substantially reduced in size, even without noticeable change in quality. This module uses pngquant to optimize png files and imgmin, which can work on various formats, but is best for JPEG files. Of course it depends on the relevant libraries (see the project description). For more information, see this recent article on the Performance Calendar blog: Giving Your Images an Extra Squeeze

Status: There is a stable release available for Drupal 7.

Image Style Pregenerate

The module, developed by Gabor Szanto, helps you to generate all the images for a new image style before enabling the style; it’s designed for bulk image generation on production sites where the performance hit of switching the image style in your field formatter without already having the new images in place, could result in issues. It relies on Views Bulk Operations (VBO) and File Entity.

Status: There is a development release available for Drupal 7.

Insert image with text

Categories: Content

The module, developed by Esben von Buchwald of Reload!, extends the Insert module to modify the image markup to include caption text below the image. I don’t know how this compares to other methods of adding an image caption, but if you are already using Insert, and you want a simple way to include image captions, this module could be useful.

Status: There are dev releases available for both Drupal 6 and Drupal 7.

Joyride

The module, written by Mark Koester of Int3c.com: International Cross-Cultural Consulting, integrates the Joyride plugin to provide a simple way to give a tour of features or information on your Drupal-based site. This looks pretty cool. Of course you need to download the Javascript and install it in your sites/all/libraries directory… and of course that means it also requires the Libraries module.

Status: There is a development release available for Drupal 7.

jQuery Tabs Field

The module, contributed by Varun Mishra, allows you to create up to seven tab fields, each with a “body” and “tab title” on any node where this field is part of the content type. On viewing the node, the module will format the output to display each as horizontal tabs, which can make for more attractive output. This is relatively simple compared to options where you could have a number of fields in each tab, but if it fills the requirements of your use case, this simplicity would be ideal. There are already quite a few sites using this and it should become much more useful when the “body” of each tab supports HTML formats (currently it only accepts plain text, but the first issue for this module has elicited a promise to get HTML support in there.)

Status: There is a stable release available for Drupal 7.

Kazoo API

The module, contributed by Bevan Rudge of Drupal.geek.nz, integrates the Kazoo REST API telecommunications platform into Drupal-based sites. This is fairly complex and the use cases for this are somewhat limited, so I’m not going to bother going into great detail, but it’s interesting to know about, nonetheless.

Status: There is a development release available for Drupal 7.

Kim Jong-filter The Kim Jong filter is used to highlight specified words or phrases within content

The module, coded by the prolific Peter Lieverdink of Creative Contingencies, provides an input filter that wraps all occurrences of names of great leaders in a <span> element with a suitable class for easy highlighting. Of course you could use it for other purposes, so this might be more than an odd novelty module.

Status: There is a development release available for Drupal 7.

Language fallback

The module, written by Peter Droogmans, a very active contributor who has done a lot for multilingual functionality in Drupal, allows you to specify a fallback language for each language on your site, so if a string is found untranslated in the preferred language, you can get the next closest language translation file. Example use cases are for regional variants of a language, so if there is no translation in “nl-be” (Belgian Dutch), it would default to a translation found in Netherlands Dutch “nl-nl” and finally default to a standard translation found in “nl”, if available. This could certainly be useful and I believe this is a backport of functionality that’s already been built into Drupal 8 “core” (if not, I suspect it will be ported to Drupal 8 as a contrib module).

Status: There is a stable release available for Drupal 7.

Layouter - WYSIWYG layout templates The Layouter module helps create templates within content to facilitate columns or other layouts.

The module, from Alexander of ADCI, LLC, provides a simple way to select a particular “layout” (e.g. columns) for content. It already integrates with the CKEditor and the developer plans support for other popular editors, but it can apparently be used without a WYSIWYG editor, too.

Status: There is a stable release available for Drupal 7.

Lazyloader filter

The module, authored by Derek Webb of CollectiveColors, provides an input filter for lazy loading images as they may appear in textareas and relies on the Lazyloader project for the actual lazy-loading of images. This module only provides a filter that renders <img> tags in a manner consistent with the needs of the Lazyloader module, while allowing you to theme the image output to your liking and preserve original image attributes. This looks useful.

Status: There is a stable release available for Drupal 7.

Leaflet MapBox

The module, contributed by Jaime Herencia of WebPartners, provides integration between another Drupal contrib module, Leaflet (which integrates the Leaflet JavaScript mapping library), and MapBox. The Leaflet module’s project page actually links to an example which uses Mapbox: The Intertwine, which documents trails in the Portland-Vancouver metropolitan region. This site really looks cool, so if mapping functionality is important for your site, this might be useful for you.
Caveat: Mapbox is not a free service, but is reasonably priced and includes some pretty cool tools and features, not to mention distributed map hosting.

Status: There is a stable release available for Drupal 7.

Link CSS

The module, created by Graham Bates of Catch Digital, allows you to add CSS files using the <link> element instead of @import. This is useful for live refresh workflows such as CodeKit which do not support files loaded with @import.

Status: There is a stable release available for Drupal 7.

Local Foodhub Local Foodhub defines the commerce functionality to support a foodhub in a community, where producers and consumers attend a regular collection day where ordered products can be collected. Foodhubs are a convenient way to provide local produce for people in the community while giving producers more regular orders.

—Project description

The module, developed by Paul Mackay, is a project description which definitely looks interesting, although there is, as of this time, no code released. Normally I don’t include modules in this column if there aren’t at least some Git code commits, but there is enough information already, and I like the idea well enough that I’m making an exception here. We need to have more local food production and distribution… and infrastructure to support this if we want to live in a future with more environmentally sustainable practices, so on behalf of my future children and grandchildren, I give thanks for people working on projects like this.

Status: Check back. Currently no project code.

Mobile Switch (Varnish version)

The module, developed by Paul Maddern of ITV, provides a simple automatic theme switch functionality for mobile devices, utilising Varnish for detecting the user-agent and providing proper cacheable pages using the same URLs per mobile device group. This helps avoid bootstrapping Drupal while still presenting the appropriate, cached content for each device type. Nice! Of course getting this all right is not simple, so be sure to peruse the project page for more complete implementation details.

Status: There is a stable release available for Drupal 7.

Moodle Connector

The module, produced by Pere Orga, aims to provide a common interface for modules that integrate Drupal with the open-source Moodle e-learning system. It does not provide any end-user features and the initial release simple adds an admin configuration page for you to enter Moodle credentials, but there are plans for some other appropriate features. If you have a site that bridges Drupal and Moodle, this could be a worthwhile module for you.

Status: There is a stable release available for Drupal 7.

Multilingual Panels

The module, created by Valeriy Sokolov, provides support for making Panels panes translatable, which could definitely be useful for multilingual sites which make use of Panels.

Status: There is a development release available for Drupal 7.

Organic Groups formatters

The module, produced by Eric Mulder of LimoenGroen, extends Organic Groups by adding additional field formatters for the “Groups Audience” field. The “Group delimited list” formatter allows you to display Group names (labels) as a delimited list. Other formatters may be added if requested in the issue queue.

Status: There is a stable release available for Drupal 7.

Panels Image Link

The module, authored by Nick Piacentine of the Mars Space Flight Facility at Arizona State University, provides a simple Panels content type to display an uploaded image and link it to a provided url/path. There are already quite a few sites using this, considering its very recent release, so I suppose this could become quite popular for sites using Panels.

Status: There is a stable release available for Drupal 7.

Pants

The module, produced by Angie Byron of Acquia, is an actual module instead of just code used in a tutorial demonstration, but the purpose is the same. The previous version of the Pants “module” (not actually released) was for Drupal 5. This project updates it to Drupal 7 code and may be used as part of Angie’s DrupalCon Sydney core conversation presentation about “Upgrading your modules”, which will cover getting Drupal 7 code ready to run in Drupal 8.

Status: There is a development release available for Drupal 7.

PDF Forms API

The module, authored by Kevin Kaland of WizOne Solutions, is an API module which you should only install if another module requires it or if you are a developer and want to use its functions, which are initially focused on PDF form functionality.

Status: There is a development release available for Drupal 7.

Pinterest Verify Website

The module, written by Peter Lieverdink of Creative Contingencies, simplifies the verication process for pinterest by adding a verification tag or page to a Drupal site.

Status: There is a development release available for Drupal 7.

Polychotomous Keys

The module, written by Ed Baker of the Natural History Museum, “allows you to build polychotomous keys using Views”. At least that is the “project description”, but currently there is not even a single code commit. While that would normally mean I’d skip the project for inclusion here, I’m interested in modules being developed for academics and there could be a lot of use cases for such a module. I’m looking forward to seeing it in action.

Status: Check back. Currently no project code available.

Prelaunch

The module, written by Dominique De Cooman of Ausy/DataFlow, allows you to set one page of a Drupal site as “prelaunch page”. An example use case might be to display a webform to collect emails to notify interested parties when your site is launched, or page with information about what’s coming. Your site can essentially be “offline” without using maintenance mode; it prevents users from accessing any part of the site besides the prelaunch page (although assigned roles can access other areas). This definitely sounds useful.

Status: There is a stable release available for Drupal 7.

Pushtape Admin

is actually a Drupal distribution for musicians, which was initially released about 18 months ago. So why am I including it here? Well, I’m not really, but there are five new Features package modules which were released in December which are all geared toward improving support for building sites with Pushtape and which might be useful even if you aren’t using the distribution. All of the following modules were contributed by Farsheed of Zirafa Works:

  • contains admin views and menus.
  • adds a simple file field to the Track content type to allow uploading mp3 files.
  • configures an event content type, view, and menu link.
  • creates a news content type, view, and menu link.
  • creates a simple photo-set to share a group of photos. Content type, views, and menu link are bundled; this also uses Colorbox.

Status: For each of these modules, there are development releases available for Drupal 7.

Radix Layouts

The module, produced by Arshad Chummun, provides responsive panels layouts set to work with Panopoly and the Radix theme (also contributed by Arshad Chummun). If you are using Panopoly, you might like Radix and if you are using Radix, you might like this module, especially if you need responsive layouts for mobile devices.

Status: There is a development release available for Drupal 7.

Restaurant

is a new distribution, also developed by Arshad Chummun, which is based on Panopoly and designed to simplify hosting websites for restaurants. Several supporting modules were also released in December:

  • provides base configuration and structure.
  • adds a blog system.
  • provides structure for creating and managing events.
  • provides structure for creating and managing menus.
  • provides structure for creating and managing slideshows.
  • adds theming helpers.

Status: There are development releases available for Drupal 7 for the Restaurant distribution and each of the listed supporting modules.

Search API Stanbol

The module, written by Stéphane Corlosquet and Wolfgang Ziegler provides Drupal integration with Apache Stanbol, a new and exciting search technology for extracting information from “unstructured” text content. Getting into the full details of how this works is well outside the scope of this column, but this definitely does look interesting. This module requires the Search API and RDF Extensions modules.

Status: There is an alpha release available for Drupal 7.

Single Image Formatter

Categories: Fields

The module, created by Federico Jaramillo of SeeD, exposes a formatter that displays one image from a multi-value image field. It allows the same options as the original image formatter, but adds an option to choose which image to display. For some use cases, the Field multiple limit may be more suitable, but the Single Image Formatter might be more efficient for situations where there are many values in a multi-value image field.

Status: There is a stable release available for Drupal 7.

Sky field

The module, created by Leonid Mamaev and Alexander of ADCI, LLC, is sort of a new, improved version of the Node field module released a few months back by the same developers. It allows you to add unique custom fields to any single Drupal entity (node, user, comment, etc). You can add text fields, long text fields, links, radios, select, checkbox, taxonomy terms, among others and includes an API to add support for additional field types. This could be very useful for sites where an occasional instance might benefit from an extra field that isn’t normally used for that content type.

Status: There is a beta release available for Drupal 7.

Twitter Web Intents

Categories: Views

The module, developed by Francisco José Cruz Romanos of Hiberus, integrates Twitter’s Web Intents system to add extra Twitter links for replying, retweeting, adding to favorites, following, etc, into a view of Twitter messages. This allows users to interact with Twitter content from within the context of your site, without needing to leave the page or authorize an app just for this interaction.

Status: There is a stable release available for Drupal 7.

Twysi

The module, created by Tony Star of Acronis, is “an amazing Twitter Bootstrap WYSIWYG HTML5 editor”, at least that’s what the project description says. But it might be a bit early to tell about the module, itself. Currently, if I install the wysihtml5 library, I can select it as the editor for a given text format, but no buttons are present and no editor shows up on a text area. That said, this does sound like a project worth checking back on.

Status: There is a development release available for Drupal 7.

URL token URL token is an API module that provides token-based authentication for other modules, where the token can be used in URLs without requiring a Drupal user. Tokens can also be limited to a set number of uses or a fixed period of time.

—from the project’s README.txt

The module, by Marcus Deglos of Techito, is “an API module to make token-based access control simple”. Normal users should only install this module if another module requires it. Developers might want to take a look at the project page for some decent code examples of how to request a token and check that a token is valid. Note: in case this is not obvious, this module has nothing to do with the Token module. “Token”, in this context, is simply an access key.

Status: There is a development release available for Drupal 7.

Views OG cache

The module, from long-time contributor Amitai Burstein of Gizra, adds a Views time-based cache, configurable per group; uses OG-context to identify a group’s view to cache; includes OG-access integration: if the group is private, caching is done per-user instead of per-group… among other listed features. This definitely looks like it could be useful for sites using both Organic Groups and Views.

Status: There is a development release available for Drupal 7.

Welcome

The Welcome module displays a custom message when users log in.The module, from Blair Wadman displays a simple, configurable welcome message when a user logs in. Simply enable it at admin/config/people/welcome, and yes Token support is included. The example message displayed at left uses Tokens for both the site-name and username. (Of course the “Swachula” username is courtesy of “Devel generate” and “d7test” is my local Drupal 7 testing environment.)

Status: There is a development release available for Drupal 7.

Yet Another Yellow Box This is mostly being used to announce weather-related school closings on sites where I've been using it.

—from the project description

The module, authored by Micah Webner of Access-Interactive, provides a simple way to add a prominent “announcement” block of filtered text to any pre-configured region. The contents and visibility of the announcement block can then be managed by users who may not otherwise have permission to manage blocks. If you have a site where staff may need to make emergency announcements, this could be a useful module to set up. See the project page for further information about how to get everything working.

Status: There is a development release available for Drupal 7 and a stable release available for Drupal 6.

Zoundation Support

The module, written by Jeff Graham of FunnyMonkey, is designed to work with the responsive HTML5-based zoundation theme and its sub-themes. It provides custom menu builder functions and blocks for menus, a foundation navbar and topbar, a custom field formatter for orbit slideshow integration, improved placeholder integration for elements, and “other minor UI improvements” that work better in this module than in the zoundation theme, itself.

Status: There is a development release available for Drupal 7.

Dec 23 2012
Dec 23
Modules of the month story banner illustration.

November 2012 was a busy month for a lot of people involved in Drupal contribution. It was the final weeks before the “feature freeze” for Drupal 8, so a lot of the focus was on new features for the next great release of Drupal. Many of the “new projects” were simply “namespace reservations” for new core modules or planned contrib modules which relate to Drupal 8; most of which had no project code committed at all (for some, presumably, it’s all in the main Drupal 8 repository). But there were also a number of new feature-enhancing modules released for Drupal 7 (and a few for Drupal 6), several which improve search functionality, a few for delivering mobile-friendly content from a Drupal site, some for commerce, others designed to help manage Drupal sites and ensure that nothing slips through the cracks when moving from “development” to “production”, among other new gems.

It’s fun, too, that we got a couple new “novelty” modules in November: one, Driesday, puts a “Happy Driesday!” message on your site every November 19th; another is a bit more insidious, with a fully-disclosed dependency on Bad judgement: Feature creep allows you to nostalgically hang onto the “good old days” when Features had a few more quirks. So if you want to remember that fun, just turn this module on and, as the module description says, “every time that you export or update a feature the Feature creep module will randomly add an extra component to your feature, what fun!”

Before we get into the module descriptions, of course, I should acknowledge the very late arrival of this month’s release of this column. It’s been one of those months… again. But let me try to hold onto my optimism that I’ll be seeing you with December’s write-up in just a couple weeks. I’ll be aiming for the first week of January. Now let’s have a look at the “new” modules.

*/ Apache Solr Term Proximity

The module, coded by the prolific Chris Pliakas of Acquia fame, should be of interest for sites using Apache Solr. It boosts the relevancy of documents in which the search terms appear closer together. In other words, if I’m searching for “data migration”, a document which has these two words together should rank higher than another document where they are separated by a few words, which should rank higher than one where these words appear in different paragraphs. Nice!

Status: There is an RC release available for Drupal 7.

bigint

Categories: Fields

It’s always nice when developers share modules which help to get around some of the native limits in Drupal. One such limit is the lack of a proper “BigInt” integer type, which might not be needed for most sites, but is certainly a limitation that developers have to work around for some use cases. The module, by Ryan Coulombe of NewMedia!, provides a true BigInt field, thus saving site builders from having to find creative ways to handle text or decimal values that they really want to be an integer. Cool!

Status: There is a stable release available for Drupal 7.

Block Group

Categories: Utility

An example “block group” to display the “user blocks”The module, by znerol, provides a taste of Drupal 8-like layouts by extending the Drupal block system with “block groups” which can be placed like a normal block, are nestable, and can have regions within them. A simple use case might be that you want all of your user-related blocks to be kept together in one “user blocks” block group, which you can then put into whatever theme region you wish, without having to always fix their order when adding them to a different theme or reorder them if you change the region. Very handy!

Status: There is an alpha release available for Drupal 7.

Book Touch

The module, which requires the Thumbnav module, is another innovation from Bryan Ollendyke of Penn State University, who has been contributing loads of great modules in recent months. It provides gestures and touch events for mobile navigation of an online book to help replicate the experience of a touch-sensitive e-book reader. Most awesome!

Status: There is a beta release available for Drupal 7.

Bounce reasons

The module, produced by Alexander of ADCI, LLC, may or may not be a good idea. It pops up a Webform in an overlay, when your site visitors attempt to close a window, where you can ask why they are leaving. Personally, I think I would just find this annoying and might likely avoid following future links to the site, but that’s just my initial reaction; maybe I’m not the typical web user and it’s possible that in some cultures people wouldn’t mind a site preventing a window from being closed to ask them why. That said, maybe it would be better to provide an “opt-in” for such an “exit poll” feature, i.e. ask visitors when they arrive to your site if they wouldn’t mind being asked about their experience when they leave. But perhaps you have a client who has asked you to build exactly this functionality? If so, rather than argue with them about why this might not be a good idea, you now know “there is a module for that”. And maybe using this for a while would help them improve their site. The project description page doesn’t specifically mention it, but it would seem to depend on Webform… and possibly also Bad judgement. Hmmm…

Status: There are stable releases available for both Drupal 6 and Drupal 7.

ckeditor_syntaxhighlighter

The module, by Jason Xie of VicTheme, integrates syntaxhighlighter into the CKEditor module by loading another yet another JavaScript project, ckeditor-syntaxhighlight. It depends on the CKEditor and SyntaxHighlighter modules, as well as the JavaScript libraries they require, installed in sites/all/libraries per installation directions (and the Libraries module, of course).

Status: There is a stable release available for Drupal 7.

Commerce Backoffice

The module, by Bojan Živanović of Commerce Guys, provides administration enhancements for Drupal Commerce and is already in use on over 2,000 sites less than a month after its release (perhaps largely since it’s a component of the latest release of the Commerce Kickstart distribution). It includes three sub-modules, each of which have a number of dependencies and the project page does a good job of explaining everything, so I won’t say more than this: if you are using Commerce and aren’t using the Kickstart distribution, you will probably benefit from adding and configuring this module.

Status: There is a stable release available for Drupal 7.

Commerce Price Extra

The module, from Marc ElBichon, adds extra features based on the price component in Drupal Commerce, including allowing ordering of price components in the cart pane, printing discounts on their own line, and other nifty features.

Status: There is a stable release available for Drupal 7.

Commerce Rules Extra

The module, also developed by Marc ElBichon, is a library of Rules events, conditions, and actions to support Drupal Commerce site building.

My wish is to merge all modules based on Rules and Drupal Commerce in a single one. It forks the apparently-unmaintained Commerce Extra Rules Conditions module. See the project page for more information about what this module already supports or to suggest additional features.

Status: There is an alpha release available for Drupal 7.

Commerce Search API

Categories: Search

The another module, contributed by Bojan Živanović of Commerce Guys, provides Commerce-specific Search API integration and fulfills a feature request that dates back to the early days of Commerce. It was covered on Commerce Module Tuesday and is part of the latest Commerce Kickstart, so is already used by many sites. If you don’t use Kickstart, and want improved search functions for your Commerce-based site, this is a good module to consider.

Status: There is an RC release available for Drupal 7.

Context Block Visibility

The module, coded by Peter Berryman, provides context for block visibility using the normal block admin page. This could be handy for certain use cases.

Status: There is an alpha release available for Drupal 7.

Dictionary Export

The module, coded by Ed Baker of the Natural History Museum, provides support for Microsoft Office-compatible dictionaries in (*.dic) format for any vocabulary on your site.

Status: There is a stable release available for Drupal 7.

Download Userpoints

The module, by Eugen, provides a way for you to allow access to private files via user points. This looks useful for communities which provide points for contribution and require points for downloads of community-contributed files (as one example use-case). It requires the Userpoints module.

Status: There is a beta release available for Drupal 7.

Drifter

The module, produced by Peter Anderson of PackWeb, allows fields to be floated to the left or right of content. While this kind of layout is normally provided by theme CSS, it can be useful for it to be theme-independent.

Status: There is a stable release available for Drupal 7.

EasyRdf

The module, from Chris Skene of PreviousNext, provides Libraries API compatibility for EasyRdf, which, in turn requires Libraries . It should only be installed if other modules require, but definitely looks useful.

Status: There is an alpha release available for Drupal 7.

Entity reference multiple display

The module, written by Jean Valverde of Linagora, provides a new field formatter for Entity Reference that let you configure different view modes for each referenced entity, for instance if you want the first elements to be displayed in full and subsequent elements to be displayed as teasers, this module could be your friend.

Status: There is a stable release available for Drupal 7.

Entity Reference Views Formatter

Categories: Fields

The module, authored by Maxim Podorov, provides a Views-based entity reference field formatter which allows you to use any view to show entity reference field value(s). It’s based on the Entity Reference View Field Formatter (sandbox) project from Katherine Bailey.

Status: There is a development release available for Drupal 7.

Facebook Autopost

The module, written by Mateu Aguiló Bosch of Human Bits, provides simple configuration to allow your site to automatically post to designated Facebook Pages. It includes a good developer API, integrates with Rules and the Entity API and includes Libraries integration for the Facebook Developer PHP SDK. It includes a Facebook app, which you authorize to make posts on the designated accounts’ behalf. There is a detailed video tutorial on the setup process linked on the project page.

Status: There is an alpha release available for Drupal 7.

Field Formatter CSS Class

The module, by Christian Zuckschwerdt, is perhaps a bit similar to the aforementioned Drifter module; it adds a CSS selector for fields so that you can select to, for example, use a class which floats an element left or right on a per-node basis. Of course you need to set up your theme for the classes and configure your fields, so it’s not a simple “add-and-activate” module, but it should give content authors a bit more control of display for individual nodes. The author invites the community to request additional features, so I think this will definitely be useful for a lot of sites (and there are already quite a few using it). Nice!

Status: There is a stable release available for Drupal 7.

Final Polish

Categories: Utility

The module, by Yannick Leyendecker of LOOM GmbH, helps take care of some of the last steps that are often forgotten when launching a Drupal site. It allows you to disable access to paths like /node, /rss.xml, etc; it uploads a “touch icon” to be used by mobile devices; it verifies the existence of /favicon.ico, /apple-touch-icon.png, etc, so that you don’t get a plethora of 404 errors in the logs, and the author invites input for additional features, but already has a nice development road-map to include checking recipients for Webform emails, checking the site email address, redirecting to the front page on errors (access denied / not found), etc. This can definitely streamline the last steps of getting our sites ready for use, so I’ll definitely be giving this a try.

Status: There is a development release available for Drupal 7.

Gumroad

The module, from Eric Peterson of Tableau Software, helps use Gumroad to sell products on a Drupal website. I normally skip over modules which integrate commercial services, but what Gumroad offers and what they charge for their services seems like a good deal. So if you want to, for instance, sell your self-produced music and don’t want to spend a lot of time (and/or money) building up e-commerce infrastructure, handling payments, and all that, this can be a simple way to collect a reasonable percentage of the incoming revenue, and start making sales, without a ton of work. Of course, if you have more involved needs for e-commerce functionality, you’ll probably want to use Drupal Commerce, but I think this module should be attractive for a lot of creatives who simply want to focus on the “fun stuff” and just sell a few things from their sites.

Status: There is a development release available for Drupal 7.

Hackpad

The module, contributed by Andrew Berry of Lullabot, integrates Hackpad into a Drupal site. Hackpad is a hosted service, based on Etherpad (but with a lot more cool, more modern features), which allows collaborative editing of documents; it’s very cool, fun, and can be used for a lot of purposes for teams, so I think the interest in Hackpad will definitely grow, as will the features supported by this module which is still new enough that the API for it has not yet been documented, but with Lullabot behind its development, you know it will be awesome!

Status: There is a development release available for Drupal 7.

Image Combination Effects (ICE)

The illustration image from the ICE project page with three pictures placed on an easel.The module, by Guy A. Paddock of Red Bottle Design, is too complex to succinctly summarize, but if you are building an image-centric site (e.g. a site to display your photography), this looks very useful for combining image effects or displaying multiple images at the same time (as one image), i.e., like “spriting” icons, but with larger images. It was designed to reduce the number of requests necessary for loading a slideshow, where they still wanted the client to be able to add new images or adjust the display order, but it looks like there could be a lot of potential use cases. It looks like this offers some pretty cool features that you might want to consider if image display is an important part of your planned site. I’ll certainly be playing with this.

Status: There is an alpha release available for Drupal 7.

jQuery Placeholder

An example of HTML5 placeholder text in a formThe module, written by James Silver of ComputerMinds, integrates the HTML5 Placeholder jQuery Plugin to provide backward compatibility, using a Javascript-only method, for older browsers which don’t support the HTML5 placeholder attribute. For those not so up on HTML5 attributes, the “placeholder” attribute provides the “placeholder text” you see in a form field before you click on it to, e.g. enter your name, but until HTML5-support improves, we need some fallbacks, so this looks like a useful module.) It requires jQuery 1.6+ and the Elements module.

Status: There is a beta release available for Drupal 7.

Legal Extras

Categories: Content

The module, contributed by Rafal W., adds additional features to the Legal module, including the option to allow a registered user to access your site with reduced permissions if they reject the “terms of use”, display the date each user accepted the terms of use, and a number of related features to help manage those annoying legal issues that might be a headache for you, too. I hope I won’t have to use this anytime soon, but it’s nice to know this module exists.

Status: There is a development release available for Drupal 6, but I suspect a Drupal 7 port will be in the works.

Mass Password Reset

The module, written by Mark Shropshire of Classic Graphics, allows a Drupal site administrator to reset the password on all user accounts (except user/1) and then notify all users. It’s good to know this module is available if there’s ever an emergency situation where we might need it.

Status: There is a stable release available for Drupal 7.

Meta tags: Panels

The module, contributed by Diogo Correia of DRI, extends the Meta tags module with support for Panels pages. It also has Features integration, so that if you export a panels page, the meta-tag configuration is exported with it. Cool!

Status: There is a beta release available for Drupal 7.

Mobile Switch Blocks

The module, written by Siegfried Neumann, extends Mobile Switch, a module contributed by the same author, to provide block visibility control for mobile devices. This sounds useful.

Status: There is an alpha release available for Drupal 7.

OG homepage

The module, produced by enzipher, allows you to configure an Organic group’s front-page as the default “home” for logged in members of the group; it also includes options to determine how a user is redirected if they belong to more than one group, among other nifty features. This could be useful for a lot of Organic Groups -based sites.

Status: There is a stable release available for Drupal 7.

Performance and Scalability Checklist

The module, contributed by Travis Carden, is similar to the popular SEO Checklist module, which he also helps maintain. It provides an interactive, step-by-step checklist to help manage the common tasks involved in launching or administering a Drupal site; in this case where it comes to optimizing your site’s software stack, from Apache to your Drupal theme.

The Performance and Scalability Checklist module interface for Drupal 7.

This module is still new and the topic it attempts to cover is so broad, that the module is sure to change and improve in time, but it already looks pretty darn useful. The author is actively seeking suggestions in the Performance and Scalability Checklist issue queue, so please give it a try, then add your 2¢ to help improve this module. Enabling this module requires the ChecklistAPI module.

Status: There is a beta release available for Drupal 7.

Performance data

The module, by Nathaniel Catchpole of Tag1 Consulting, is envisioned to be a UI for viewing and analyzing performance data that you’ve recorded and saved using other tools. When a key core maintainer starts a new project, there’s usually reason to take notice and expect there might be great things coming. That said, according to the project page, this is still in the early stages of development, so unless you have an interest in assisting the development process, you might want to wait a while to try it out.

Status: There is an alpha release available for Drupal 7.

Print Anything

The module, coded by Chris Desautels of R2integrated, helps you configure special rules for generating print-friendly output for any path. There is some work to getting it all working, but it has some nice features and helps you handle a lot of content that isn’t otherwise simple to print, as well as helps maintain your brand visibility by including your logo in the output, among other features.

Status: There is a stable release available for Drupal 7.

Quo.js

The module, created by Bryan Ollendyke of Penn State University, integrates the Quo.js mobile event library into Drupal. As with other such modules, you’ll still need to download and install the JavaScript code, separately. It provides a number of features, including environment detection, and event detection, such as reading “tap”, “hold”, “pinch”, “rotate” and other such mobile gesture events. It integrates well with, and enhances, the other modules recently released by the same prolific contributor, including the aforementioned Book Touch and Thumbnav modules, so it certainly looks useful and I expect it will grow in use as more sites start providing mobile-specific features.

Status: There is a beta release available for Drupal 7.

Search API Page Block

Categories: Search

The module, produced by Tobby Hagler of Phase2 Technology, uses the Search API Page module to perform a search using the currently viewed node’s title as keywords, displaying the results in a block, so you can direct users to related content.

Status: There is a beta release available for Drupal 7.

Simple Anti-Spam

Simple Anti-Spam user interface for Drupal 7.The module, by xandeadx, adds two new elements to designated forms: one checkbox, labeled “I’m not a spammer” and a hidden checkbox, “I’m a spammer”. If user does not check the first or (is a bot which) has checked the second checkbox, the form is not submitted and displays a warning message.

Status: There is a development release available for Drupal 7.

Simple Table of Contents

Categories: Content

The module, coded by Devin Carlson of Ontario’s Ministry of Northern Development and Mines, automatically adds a table of contents to all of your node content, as long as the content is within the node’s “body” field. It’s a simple add-and-enable module which presumably depends on normally-structured content (with headings, etc.)

Status: There is a stable release available for Drupal 7.

Speedboxes - Fast checkbox handling

The module, produced by Manuel Pistner of Bright Solutions GmbH, provides a Javascript-based method to easily check, uncheck, or invert the current setting of a selected range of checkboxes in a grid, e.g. the Drupal permissions page; simply click and drag over a selection of checkboxes and a toolbar appears which allows you to modify the state of all the selected checkboxes. Too cool!

As an alternative to the module, the Bright Solutions blog also includes post about how to use speedboxes as a browser plugin so you can benefit from this feature on any page you visit with your browser.

Status: There is a stable release available for Drupal 7.

Thumbnav

The module, yet another module produced by Bryan Ollendyke of Penn State University, provides a mobile-friendly framework for using a website on touch-driven devices, with support for a variety of navigation methods and an API for developers. It includes support for Quo.js, but doesn’t rely on Quo. See the project page for links to some nice demonstrations, but if you are looking for ways to improve your site’s mobile support, this could definitely be worth checking out.

Status: There is an alpha release available for Drupal 7.

Unit Conversion Formatters

The module, developed by Tony Rasmussen of Metal Toad Media, provides formatters for number fields to convert values between any unit supported by the Units API module. This could certainly be useful for some sites.

Status: There is a stable release available for Drupal 7.

Views Drupal 7 to Drupal 8 upgrade

Categories: Views

BACK UP YOUR DATABASE BEFORE ATTEMPTING TO USE THIS MODULE FOR AN UPGRADE. Really. We're not kidding.

—from the module’s project page description

The module, written by Jess of University of Wisconsin-Madison, a major force behind getting “Views in core” in Drupal 8, helps migrate Drupal 7 Views data to Drupal 8. It’s nice to see work on this is this far along.

Status: There is a development release available for Drupal 7 (really a Git repository you can check out).

Wunderstatus connector

The module, from Henri Hirvonen of Wunderkraut, sends information about installed modules as a JSON to a central service. This could be useful for monitoring a group of sites your company maintains, so I look forward to giving this a whirl and seeing how it develops.

Status: There are alpha releases available for both Drupal 6 and Drupal 7.

XSL Formatter

The module, developed by Dan Morrison of Sparks Interactive, provides a field formatter to process XML content through a defined XSL stylesheet for rendering. If that sounds useful, it’s probably best you just look at the well-written project page, because there is quite a lot of information there, which runs well outside the scope of this column.

Status: There are dev releases available for both Drupal 6 and Drupal 7.

Dec 13 2012
Dec 13

I ran into a situation in which I created a new Input Format in Drupal 6 on a site that had a lot of content. This input format was similar to the default Filtered HTML input format, however I wanted it to have a few different options.

I wanted all anonymous users to only be able to access the Filtered HTML input format, but authenticated users (or users with specific roles) to be able to access this new input format. This part was easy with Drupal's administration interface the problem came when I wanted to change the input format for the body field for all the posts on this site to the new input format.

I really did not want to go into each post one by one, scroll down to the body field, and change the input format, so I came up with a quick database solution using MySQL.

The node body field data is stored in the node_revisions table in the MySQL database. In this table there is a column called "format" that contains the id of the input format that is being used on that post. I only wanted to change this for a few content types, not every content type on the site, I also only wanted to change it for content that was published (leaving the unpublished content alone).

The first step was to look up the input format in the filter_formats table to get the correct new format id to use. Depending on the type of database viewer you are using (PHPMyAdmin, MySQL Workbench, Command Line MySQL, etc) this might be slightly different. You can probably click on the database table to see the records or you can run

SELECT * FROM filter_formats;

This will give you something like:

In my case the format ID I needed was 4. Now I needed to construct the MySQL UPDATE query to go into the node_revisions table and update all the posts that were of the specific content types I needed that were also published. I also only wanted to change the ones that were set to Filtered HTML (leaving any other formats unchanged).

The query I constructed looked like:

UPDATE node_revisions AS nr
INNER JOIN node AS n ON nr.nid = n.nid
SET nr.format = 4
WHERE n.status = 1 AND n.type IN ('blog', 'content_2') AND nr.format = 1

Note: Be careful with this. Anytime you are editing the database manually you risk messing things up. I would suggest making a backup prior to doing this if you are unsure of what you are doing. Also, if you are using revisioning (which I was not in this example), this will cause some inconsistencies as this change should probably be registered as a new revision. In this case you might want to look into writing a Drupal script in PHP to load the nodes in question, change the status, and then execute a node_save. The MySQL route just happened to be easier for me.

Dec 13 2012
Dec 13

There are a lot of approaches for resizing images (ImageCache, Image, iMCE, and many others). However when building a site for a simple user (no previous web experience), I found that all of these approaches required too much effort on the part of the end user. Why can't a user just resize an image in their WYSIWYG, and not worry about the size of the image at all? That's the goal accomplished by the Image Resize Filter. Despite its extremely techie-sounding name, it's ridiculously easy to use. It provides inline resizing of images to match any tag in any HTML inserted in any Drupal textarea that supports filtering.

Nov 23 2012
Nov 23
Modules of the month story banner illustration.

October 2012 brought us a nice batch of interesting new modules. Of course I wanted to tell you all about them weeks ago, but without going into excuses and details, I’m afraid getting this published didn’t go as planned. I’d like to get back on schedule to release the next installation of this series in early December, though. Anyway, it’s great to see all of the innovations that have been introduced in the past month. You can tell that Drupal 7 has truly reached maturity by the kind of modules that are being released now. Many, if not most, of the new modules integrate with and extend the functionality of other contributed modules—for example, there are three new modules which provide plugins for the Facet API—or integrate exciting new jQuery plugins to bring a bit of sizzle to your site.

As usual, the list is in alphabetical order and I haven’t tried all of these modules (although I have experimented with quite a few of them and even eliminated a few from consideration since they seemed a bit too “broken” at this point.) Some of these modules might not be ready for use yet, but just show good promise and look worth keeping an eye on. Creating this monthly list is as much for me as it is for you, but I do hope that the modules I select work well for you, if you give them a try, and I look forward to seeing your comments about any of these modules.

*/ Adminimal Administration Menu It adds a nice and simple minimalist look and provides some tweaks to improve your Drupal administration experience. The menu hierarchy is now simpler and easier to understand […] The shortcuts fit nicely and have a small icon that separates them from the normal admin menu links.

(Adminimal Administration Menu project description)

The module, by Andonis Ratsos, changes the style of the popular module’s menu bar.

The adminimal_admin_menu look and feel

Whether or not you like the way it restyles the Admin menu is likely a matter of personal taste, but I do observe that even with only the default shortcuts in the menu (no custom shortcuts added) the larger font of the menu makes it take up a lot space at the top of the window and it starts to wrap to a second line if the window is narrower than about 1,100 pixels, so it’s possible that people administering Drupal sites from smaller devices (netbooks or tablets, not to mention smartphones) might find this modification less appealing. On the other hand, the larger links should make easier targets for a finger-tip… six of one, half a dozen of another.

adminimal_menu shortcuts

Personally, I like the theme change and I like the Adminimal Adminimal Theme admin theme, too, so for my personal testing sites, I’ll go ahead and leave these active. I’m hoping to see some simple customization available in the future… I think I would want to see that before recommending it for client sites.

Status: There is a development release available for Drupal 7.

Autocache

The module, by Teemu Merikoski of Wunderkraut simplifies caching of Views and Panels and has some support for appropriate clearing of Varnish caches, too. It’s still new and the roadmap is perhaps a bit longer than the current features list, but I’m sure that this will be worth keeping an eye on.

Status: There is a development release available for Drupal 7.

Bootstrap optimizer

The module, by Maslouski Yauheni, has only been released for a couple of weeks and there are already over 150 sites using it, so it must be worth a try! On the other hand, if you don’t “improperly delete” modules, perhaps it’s not so useful for you. It appears that its primary functionality is to remove modules from the system table which no longer exist in the modules directory, so if all your sites are well-maintained, this might not do much for you. It looks like Drupal 8 should hopefully resolve this issue. But until this is really fixed in core, there is a place for modules like this, especially for older projects that might not be very actively maintained and might have had some modules deleted over the time. For such sites, this module claims to provide a several-fold increase in the bootstrap time, and provides screenshots as evidence.

Status: There is a beta release available for Drupal 7.

Bulk User Delete

The module, produced by Mark Theunissen of Four Kitchens, provides with a text area where you can enter a list of email addresses for users you wish to “bulk delete”. Normally, it’s probably easier to simply check the boxes next to the names of a group of users you wish to delete and select the action “Cancel the selected user accounts”. But I can imagine scenarios, especially scripted ones, where using this module might be a simpler solution, e.g. when creating a number of test users en masse, users with various combinations of roles and/or other custom relationships, and then removing them after the tests have been run. This could be useful if you want to run such tests on a busy production site without needing to take special care that you select only the right users for deletion or when you have so many test users that they wouldn’t all be visible on one page of users.

Status: There is a stable release available for Drupal 7.

Cache Lifetime Options

The module, from giorgio79, provides additional cache-time options which can be selected on admin/config/development/performance, with cache lifetimes up to a year. This is especially useful for sites with a lot of static content. Boost is a recommended companion.

Status: There is a stable release available for Drupal 7.

ceaZine

The module, written by Carlos Espino Angulo, allows you to display PDFs in a Colorbox overlay with “page flip” effects and everything. If you want a nice effect for showing off your books, this is a great module. Setting it up is a bit involved, though, so be sure to check the project page for full details. It requires a few of jQuery libraries, and (of course) a recent version of the Libraries module, Views (for an included display of all your online magazines, if you wish to use it), and PDF to ImageField which, in turn, requires ImageMagick, but it uses only CSS, JS, and HTML—no Flash. Nice!

Status: There is a stable release available for Drupal 7.

CkEditor Plugin: Google Doc embedded iframe

The module, authored by Sergio García Fernández, is an extension for the popular CKEditor module, which provides a simple editor button for easily embedding Google Docs iframes in your content.

Status: There is a stable release available for Drupal 7.

Cloze

The module, written by Sivaji Ganesh of KnackForge, provides Cloze question type for the Quiz module. Cloze questions are the type of question where blanks are inserted in the middle of questions, a question type commonly used in language assessments.

Status: There is an alpha release available for Drupal 6.

CodeMirror editor

The module, developed by Darren Mothersele, adds syntax highlighting directly to your Wysiwyg editor experience, using the Codemirror Javascript library, among other nice features. If you have a site where writing and displaying code is important, this could well be useful. It doesn’t even require WYSIWYG (although there are, perhaps, more fully developed alternatives if you simply want syntax highlighting for code entered in a basic text area), much less any particular editor. It’s still under active development, but the plans look interesting, so this is definitely worth keeping in mind for projects which involve presenting code.

Status: There is a development release available for Drupal 7.

Collapsible comment threads

The module, developed by Manuel Garcia, uses jQuery to collapse and expand comment threads, thus helping remove the “visual noise” of deeply threaded comment conversations. This could be especially useful for sites with a forum or very active discussion in blog comments.

Status: There is a beta release available for Drupal 7.

Content Access Admin

The module, by Peter Lieverdink of Creative Contingencies, lists all node grants in a simple table. This is especially handy since special access grants, provided by the Content Access module, are otherwise only visible on the individual nodes.

Content Access Admin displays a table with some filters to see just what you want to, with links on each node title to help you jump right to each node and manage the access.

Status: There is a development release available for Drupal 7.

Date Facets

The module, contributed by Chris Pliakas of Acquia, provides date range facets similar to major search engines so that you can look for search results within a defined date range. Too cool! It integrates with the range of search modules available for Drupal, including Apache Solr, among others. Of course it’s search technology, so implementing it is not as simple as activating the module.

Status: There is a beta release available for Drupal 7.

Dates

The module, created by Chris Charlton of XTND.US, is not actually part of the Date module, but provides a range of additional advanced date formats. This could be especially handy, but beware that disabling or uninstalling this module does not remove the packaged date types and formats which are stored in the Drupal database when the module is enabled.

Status: There is an alpha release available for Drupal 7.

Devel Input Filter

The module, contributed by Garrett Albright of PINGV, aids development of input filters; it provides a page where you can enter test input to see filtered input, without caching. It’s really only for developers who are debugging text filters.

Status: There is a development release available for Drupal 7.

Email Log

The module, authored by Mikael Kundert of Wunderkraut, allows site maintainers to get email notification when there are critical log entries. Log entry tokens would need to be supported for this to be done by Rules, but even so, it greatly simplifies staying on top of important site updates. The user interface and options are almost exactly the same as the Watchdog Digest module’s, except that this module will send you an alert whenever there is a watchdog entry of a given severity level, so you might wish to send only the most critical alerts with this module and use Watchdog Digest to send an email which includes all the other log entries in one email.

Status: There is an RC release available for Drupal 7.

Entity Translation Tabs

The module, contributed by Ryan Weal of Kafei Interactive, gives site editors an edit tab for each enabled language. For the time-being, it only supports nodes, but the roadmap includes support for other entity types, e.g. taxonomy and user entities, among others. This should be great for multilingual sites! It is currently in active development, so I won’t list the potential caveats. Please see the project page for recommended usage.

Status: There is a stable release available for Drupal 7.

Facet API Collapsible The search facet links from Facet API Collapsible

The module, by Peter Droogmans of Attiks, is a “full project” release of a sandbox project created by Acquia’s Katherine Bailey. If the name doesn’t make things especially clear, it probably helps to understand that the Facet API is another Drupal project, which this one extends (although the project description leaves that part out). Faceted search (e.g. searching within a range of pre-selected terms or dates) is what the Facet API does and this widget provides a slick interface for single-click searches.

Status: There is a stable release available for Drupal 7.

Facet API tabs

Categories: Search

When it rains facets, it pours facets. The module is another widget for the Facet API, written by Erno Kaikkonen of Exove Ltd in Finland. It allows you to display search facets in tabs and the project description indicates you’ll want to do “some CSS work to style the tabs”. If a sidebar isn’t what you need, this might be the ticket.

Status: There is a beta release available for Drupal 7.

Field collection feeds

The module, contributed by Howard Ge, provides feeds integration for field collections and also requires Feeds. This could well be useful.

Status: There is an alpha release available for Drupal 7.

Field Collection Tab formatter

Field Collection Tab Formatter imageThe module, written by Lee Rowlands of Australia’s PreviousNext gives us a nifty output for field collections in a tab-set. I can think of at least one place I’d personally like to use this and apparently I’m not the only one since there are already more than 50 sites using the module, barely a month after its release… a pretty solid start! Of course it requires the Field Collection module.

Status: There is a stable release available for Drupal 7.

Field formatter conditions

The module, written by Kristof De Jaeger of Wunderkraut, adds conditions to field formatters. The “Manage Display” tab for each entity type provides per-field configuration of field conditions. It supports fields from the Field API and Display Suite with a number of included conditions and it requires Field formatter settings

Status: There is an alpha release available for Drupal 7.

Flipcard - nodes made into flashcards

The module, by Hugh, helps you create node-based flashcards where the node title is the “answer”. Users can sort based on custom taxonomies and can record whether they knew the answer to each card, so questions they are still having trouble with will show up more often. I used to cut up index cards to make actual paper flashcards to study for exams and more recently, but still some years ago, made them to study on an old Palm device, with great success, so I know the usefulness of flashcarding, but this even offers jPlayer support to use automatically-played audio recordings for the questions. Very cool! You can see the demo site, where you can also learn a bit of Thai, to get an idea of the usefulness this module already offers. There are always new things I’m trying to memorize, so I’ll be a likely candidate to give this module a try. The only thing I’m really hoping it will offer (that I didn’t notice in the demo) is the ability to use the “question” as the “answer” (i.e. to practice both directions), but I doubt that would be too hard to manage. The demo site already offers the option to “view words” (clicking on each word in English takes you to the audio recording of its equivalent in Thai, whereas in practice mode, you hear the word and check to see if you know what it means). Personally, I think the current mode is better for the initial phase of passive comprehension, but for learning to actively speak a language, it’s better to work from “mother tongue” to “other tongue”. So ideally, the module should support working in both directions and keeping track of your answers in both directions, too, but maybe all this is already in the development roadmap.

Status: There is a development release available for Drupal 7.

Invites

The module, developed by Raz Konforti of Linnovate, allows you and/or your site members to invite new members to your site and includes an OG module to provide for inviting people to a particular group; it provides for the creation of a custom, fieldable Invites type and for custom invitation emails with Rules integration, among other interesting features. Google has proven the power of viral campaigns to build a community around a new product with “invitation-only” access… so this could definitely be a good idea for your community site, too. Note: Administrators of OG sites might, alternatively, wish to use the OG Invite People module, which eliminates the registration process for invitees.

Status: There is an alpha release available for Drupal 7.

jQuery selectBox Styles of SELECT element provided by the jQuery selectBox module.

The module, produced by Henry Umansky, provides multiple Javascript-enhanced styling options for SELECT elements. It integrates Cory LaViska's selectBoxjQuery library plugin, so like most such integration modules, it requires the Libraries module as well as the afore-mentioned and eponymous selectBox jQuery library installed in sites/all/libraries, according to the nicely detailed directions on the project page. The selectBox demo is really freakin' cool! There are various options for slick effects in addition to the various ways of building a SELECT box for improved UX.

Status: There is a beta release available for Drupal 7.

JS Watchdog

The module, coded by Bevan Rudge provides Drupal.watchdog() in Javascript to log errors to the database. It’s really mostly a developer tool for people working on Javascript code, but this should be useful. It provides a number of nice features, though, so if you are working on JS code, you might want to take a look at this. Unfortunately, there isn’t a Drupal 7 version (yet), but according to the project page, creating one should be “trivial”, so hopefully we’ll have a nice D7 version ready for use before long, too.

Status: There is a beta release available for Drupal 6.

Leaflet Widget for Geofield Simple geometries supported by the Leaflet Widget

The module, developed by Tom Nightingale of Affinity Bridge, a Geofield widget that provides a Leaflet map and uses the Leaflet widget plugin to work with geometries, making it possible to, for example, mark up web-based maps with the outline of a real estate propery or city district. Of course it requires Libraries and configuring any kind of mapping is never as simple as just activating a module, so be sure to check the project page for more details.

Status: There is a beta release available for Drupal 7.

Logo Block

The module, authored by Kristofer Tengström, provides flexibility in how you display your site logo, including applying an image style, and provides a block you can place anywhere, thus circumventing the limitations of the Drupal logo configuration.

Status: There is a stable release available for Drupal 7.

MC Hammer

The module, written by Nils destoop of Wunderkraut, provides tools and templates for sending sophisticated email newsletters from your Drupal site. There is only a development release, so far, but it already has an impressive feature-set, so if you plan want to produce a newsletter, this could be a great tool to look at, and with Wunderkraut behind this, we can bet this will develop nicely.

Status: There is a development release available for Drupal 7.

Nice Date This is the kind of date display provided by Nice Date

The module, written by Nicholas Thompson of Turner Broadcasting Systems, provides a nicely formatted date to display the publication date of nodes, e.g. blog posts, and comments. It uses a CSS Sprite with all the months, days and years to generate a 41x40px block with the date in it.

Status: There is a stable release available for Drupal 7.

Node Display Field

The module, contributed by Christian Biggins of PreviousNext, provides an alternative teaser display mode which can be enabled for any node, e.g. a “promo” mode. This could be useful.

Status: There is a development release available for Drupal 7.

No term pages

The module, written by Gaël Gosset of Insite, provides an extra option for a vocabulary which blocks the terms in that vocabulary from ever being displayed as a page. With all the different ways that terms are used in a typical Drupal site, not wanting term pages for some vocabularies is a pretty common use case, so now you know—there’s a module for that! This functionality should probably be in “core”.

Status: There is a stable release available for Drupal 7.

OG Invite People

The module, developed by Aleš Rebec, has some features in common with the previously-mentioned Invites module, but it’s only for Organic Groups. One interesting feature of this module is the complete elimination of the registration process. A user entity is during the invitation process and the invitees receive a one-time login link in their invitation emails.

Status: There is a development release available for Drupal 7.

Panels Content Cache

The module, developed by Graham Taylor of Capgemini, provides a content-aware cache plugin which supports caching Panels and other Ctools displays, until their content changes. Isn’t that how caching should work? Caching strategies and the technologies that support them are not trivial and there are a number of options, but this module looks promising for those who are working with Panels content.

Status: There are dev releases available for both Drupal 6 and Drupal 7.

Permissions Grid The simple permissions UI provided by the Permission grid module Links to the Permissions grid on the general permissions page.

The module, by Joachim Noreiko, provides a per-role grid of permissions for modules which declare structured permissions. These permissions can be viewed, on a separate page for each role, with the entity types in rows and permission verbs in columns. Of course it doesn’t eliminate the normal sea of permissions… but for the basics related to your site content, this helps simplify things. This is very nicely done and I’ll be sure to use it.

Status: There is a stable release available for Drupal 7.

Retina Images

The module, contributed by Michael Prasuhn, provides the option for core image styles to output a high resolution version of images for high DPI or retina displays. It can be used to return high resolution images for all devices. There can be very little difference in file-size between a low-resolution, high-quality image and a high-resolution, low-quality image. But the high-resolution image will work better on high-resolution devices and still look fine when scaled down for display on a normal-resolution monitor. This module already has a strong user-base, considering its recent release and the developer seems to be doing a great job managing the issues, so if improving mobile UX is important for your site, this module might well be worth considering.

Status: There is a beta release available for Drupal 7.

Rich Snippets

The module, developed by Chris Pliakas of Acquia, enhances the search results to provide nicer “snippets” of content returned in search results, much like those displayed by major search engines. Instead of just displaying the teaser or first characters of an article, it displays that with ellipses and the user’s search term within the context of the content. Very nice! Caveat: Be sure to read the “Usage” and “Gotchas” on the project page. Configuring a perfect site search is a non-trivial task, but this definitely looks helpful and works with core search and Apache Solr.

Status: There is a development release available for Drupal 7.

Role memory limit The simple configuration for the role_memory_limit module.

The module, developed by Kevin Yousef, is a small module which allows you to configure separate PHP memory limits, per role. For normal users, the memory limit could be set to 128MB, while the admin interface, which can require much more memory, can be allocated what it needs. Of course you need access to change the memory limit in your php.ini file. Since the memory limit is set per-user and this often has to be higher than normal for a Drupal site, just because of the greater needs for the site administrator, logical configuration with this module could, in theory, dramatically improve the number of concurrent users your site can handle. I’ll certainly be giving this a try.

Status: There is a stable release available for Drupal 7.

Scoville

The module, produced by Garrett Albright of PINGV, which gets its name from the “hotness” scale used for describing a variety of chili pepper’s level of spiciness, helps you easily display a block or page of your site’s “hottest” content. For more complicated use cases, you’ll probably want to use the Radioactivity module, instead, but since configuring it can be a bit of a chore, people who just want to get a basic “hot content” block into their site might want to give this one a try.

Status: There is a development release available for Drupal 7.

Search API Taxonomy

Categories: Search

The module, developed by Steven Jones of ComputerMinds, adds some extra features for integrating taxonomy into the Search API, including indexing the taxonomy term parents and display of a facet (using Facet API) for top-level terms. It’s still in development, so additional features could well be added, but this already looks very useful.

Status: There is a development release available for Drupal 7.

Taxonomy Freetag Detection

The module, by Leigh Morresi, extends Term reference fields of type Autocomplete term widget (free tagging) with an option to add a button to scan other fields (e.g. your node “body”) to and add words which it finds which match existing terms in that vocabulary. Of course you might need to eliminate any terms it adds, e.g. a word in your document might match an existing term, but have the wrong context for the meaning of the term (e.g. “Features” is a taxonomy term here on the Cocomore Drupal site, but if I simply talk about the features of a module, I’m not going to tag the article with that term). This looks pretty simple and very useful, especially if your site uses the standard autocomplete “tagging” widget, which is the only widget this module complements. See the project page for configuration tips.

Status: There is an alpha release available for Drupal 7.

Twitter Profile The Twitter Profile module in demo use.

The module, created by Rishikesh Bhatkar, provides a nice, very configurable, Twitter profile block which can show any or all of: your Twitter profile info, counts for Tweets, Favorites, Listed, Followers, and Following, and avatars for your Followers and Following, with a configurable size and number of avatars displayed. It also includes some theming presets for the block. This is much more configurable than many of the other Twitter blocks. What would be nice for community sites would be allowing each user to display their Twitter profile on their user profile page, but it looks like the block only supports one Twitter account.

Status: There is a stable release available for Drupal 7.

User Pic Kit

The module, written by Daniel Phin, allows your site’s users to choose a user image (avatar) to represent their account, from any of a number of providers, while still supporting a Drupal core image upload option. Each user can choose which provider they wish to use. The included third-party image host providers include Gravatar (which requires the Gravatar integration module) and Robohash, but with the add-on User Pic Kit Extras! module, you can add Twitter, Facebook, and other avatar hosts. You can also locally cache the remote pictures (such as Gravatar) and use Drupal image styles on the downloaded pictures! There is even a documented API which allows you to implement other image hosts. This looks like fun and can certainly improve the user experience for configuring a new user account profile for users who already have an established online persona.

Status: There is an alpha release available for Drupal 7.

User Search to People Administration

The module, developed by Benjamin Melançon of Agaric, removes the user search functionality from your site (for normal users) and moves it into /admin/people/search (a tab on the /admin/people). Most sites probably have no need for visitors to search user accounts, but administrators can still find such a search useful. By moving the user search tab into the “admin realm”, this also opens up the option of allowing people to view user profiles without also providing the “search users” functionality (since, by default in Drupal 7, if you want to block access to /user/search for a particular role, you need to leave the permission to “access user profiles” unchecked. So in addition to moving the user search functionality into a tab where it’s convenient for site administrators, it also breaks this unnecessary relationship between access to user profiles and to using the user search feature. This looks useful for many common use cases, perhaps even more ideal for most sites than the Drupal default.

Status: There is a stable release available for Drupal 7.

View mode per Role

The module, developed by Edouard Cunibil allows site administrators to set a view mode for content depending on the user role, with configuration in the content type edit form. This can be useful when you want your content to be displayed differently, to different user roles, but do note that this is not a content access module, so if you must prevent certain roles from being able to gain any kind of access to certain fields, you should consider the Field Permissions module.

Status: There is an alpha release available for Drupal 7.

Watchdog digest

Configuration for the Watchdog digest module.The module, created by Edgár Prunk-Éger, sends watchdog entries by email in a digested format, so you don’t get a separate email for each entry (of a type where you might want to send a message to a site administrator). This looks very useful, but the current project page is very lacking in detail and there is no link to the configuration, so it took looking at the code to figure out where to adjust settings for this. It adds a fieldset to the “Logging and errors” configuration page (/admin/config/development/logging), where you can configure the number of messages per e-mail, the e-mail address(es), and the severity level threshold, which can be set anywhere between “debug (all)” and “emergency”, although probably for anything that extreme you might want a Rules-triggered action to immediately email the site administrator.

Status: There is an alpha release available for Drupal 7.

WYSIWYG Configuration with TinyMCE and Shortcodes

The module, coded by Jurriaan Roelofs, is a Features-generated module which helps streamline a particular Wysiwyg configuration which is rather sophisticated. If it happens that you want all the features included here, it could be a nice way to get it all configured. But if you want something simpler or wish to use a different editor, etc, this is probably not for you. It includes Media integration and all kinds of things that a lot of sites won’t use, but which are notoriously tricky and time-consuming to work out, so if this kind of rich configuration is what you want, then all you need to do is download all the dependencies (see the project page, there are a ton!) and then simply enable this module to have it automatically enable and configure all its dependencies. This looks very useful if it happens to be exactly what you need; if not, it could be also be useful as a quick route to experimenting with a lot of modules and features that you might want to use.

Status: There is a beta release available for Drupal 7.

Nov 05 2012
Nov 05

How to Tidy URLs and Relative Links When Moving From Dev to Go-Live (for Drupal 6 and 7)

Few things are as annoying as building something that works perfectly when you create it, but fails when you take it out of the lab. That's how site owners can often feel when content editors create piles and piles of Drupal nodes full of relative URLs in images and links. They look fine on the site, but if the content is syndicated via RSS or Atom, sent out in an email, or otherwise repurposed in another location, the links break. Even worse, hand-made links and images entered while the site is under development can easily point to the outdated "beta" URL. Who can save the day? Pathologic module, that's who.

Pathologic module's configuration options

Pathologic is an input filter -- to install it, you drop the module into your Drupal site and add it to one of your text formats -- Full HTML and Filtered HTML, for example. Whenever content is posted in a format configured to use Pathologic, it will scan the content for URLs and tidy them up. Relative URLs like /node/1 get turned into absolute ones like http://example.com/node/1, URLs pointing to alternative versions of your site like dev.example.com are replaced with your public URL, and so on.

Pathologic can also standardize the protocol of links inside your site's content. If users edit content over a secure connection, for example, it's easy to mix links using the http:// and https:// protocols -- something that can lead to annoying warnings on some users' machines. For developers with exacting URL-correcting needs, it also supports custom URL modification hooks. Using those hooks, your site's custom fixes (replacing MP3 links with a URL on a different server, for example) can piggyback on Pathologic's configuration and logic.

Pathologic is an efficient workhorse of a module that solves an annoying problem efficiently. If you've run into problems with relative links and staging-server URLs breaking links and images on your RSS feeds, you owe it to yourself to check it out!

*/
Oct 31 2012
Oct 31

On a recent Drupal 6 multi-currency Ubercart website I came across the following requirements.

  • I needed to save a users preferences to determine whether to display prices with VAT or not
  • I needed the user to be able to manage these preferences from within their account settings
  • When the user purchased something, either for the first time, or multiple times, I needed their preferences to be updated

In this post I will go over part of my solution to solve these requirements. My implementation is just one of many ways that I thought about building this solution out. Here is what I did.

Drupal 6 content_profile module

I installed the Drupal 6 content_profile module and created a simple preferences content type for storing a users preferences. The main field of note here is a country field (I had other fields in the content type). To ensure that the field contained the correct Ubercart countries and the correct numeric values, I used the following PHP to build out the available options. Note: I broke this out into a function inside a custom module and just called the function inside the available options PHP code section. Most of this code was borrowed directly from the Ubercart module.

$order_by = 'country_name';
$result = db_query("SELECT * FROM {uc_countries} WHERE version > 0 ORDER BY country_name");
 
$options = array();
while ($country = db_fetch_array($result)) {
  $options[$country['country_id']] = ($order_by == 'country_name') ? t($country[$order_by]) : $country[$order_by];
}
if (count($options) == 0) {
  $options[] = t('No countries found.');
}
natcasesort($options);
 
return $options;

Implementing the hook_uc_checkout_complete Ubercart hook

The next step was to make sure that if a user checked out of the store, that their preferences would either be updated (if they already existed) or created (if this is a new user). This way, when a user logs back into the site, they will see the prices as they originally have specified based on their country. I was originally going to use hook_order, but decided instead that the hook_uc_checkout_complete hook was the much easier solution. Here is an example of my hook_uc_checkout_complete implementation that updates or creates a "preferences" content type based on the orders billing country.

/**
 * Implements hook_uc_checkout_complete().
 */
function MYMODULE_uc_checkout_complete($order, $account) {
 
  // Get the nid of the existing preferences node.
  $sql = "SELECT n.nid FROM {content_type_preferences} ctp
    INNER JOIN {node} n ON ctp.nid = n.nid
    WHERE n.uid = %d";
  $result = db_fetch_object(db_query($sql, $account->uid));
 
  // Check if the user has a preferences node created.
  if (isset($result->nid)) {
    // Load the full node object.
    $node = node_load($result->nid);
 
    // Set the country field.
    if (isset($country)) {
      $node->field_country[0]['value'] = $order->billing_country;
    }
 
    // Set other fields if needed.
 
    // Save the updated node.
    $node = node_submit($node);
    node_save($node);
  }
  else {
    // We need to create a new preferences node.
    $node = new stdClass();
    $node->type = 'preferences';
    $node->title = $account->name . 'Preferences';
    $node->uid = $account->uid;
    $node->name = $account->name;
    $node->comment = 0;
    $node->promote = 0;
 
    // Set the country fields value.
    if (isset($country)) {
      $node->field_country[0]['value'] = $order->billing_country;
    }
 
    // Set other fields values if needed.
 
    // Create the node.
    $node = node_submit($node);
    node_save($node);
  }
}

Additional notes

I also added some settings to the users $_SESSION variable to handle displaying things for anonymous users. I won't go into all that detail here, but it is an important note.

hook_uc_checkout_complete and content_profile conclusion

The above was only a small part of my total solution to get this working but was one of the most important pieces to the puzzle. If you need an example on how the hook_uc_checkout_complete Ubercart hook can be used or how to create a content_profile node programmatically, the above code should be able to help you out.

Any questions or comments? Let me know below.

Oct 12 2012
Oct 12

Note: Turns out there is a much easier way to do this as there is an Ubercart function that does essentially the same thing (thanks to the comment below that pointed this out). Just use:

uc_product_is_product($node);

I left the original post below (although it is no longer really needed).

I have seemed to run into the issue of trying to determine if a specific Drupal 6 node is an Ubercart product content type a few too many times. There are many ways to verify this from checking the Drupal database in the uc_products table, to looking at the Drupal node object for a sell_price attribute (or other Ubercart attribute), etc. Here is the way that seems to work the best for me and that I will be using from here on out.

I have put this in a Drupal 6 hook_nodeapi implementation to try to demonstrate a practical Drupal example:

/**
 * Implements hook_nodeapi().
 */
function MYMODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  //print('<pre>'.print_r($node,1).'</pre>');
  if ($op == 'view') {
    // Check if this is a product node.
    $node_types = uc_product_types();
    if (in_array($node->type, $node_types)) {
      // Do something with the product.
    }
  }
}

Overall it is pretty easy, but just wanted to get this put up somewhere to not only help others, but to also help myself the next time I run into this situation. Any questions or comments? If so, let me know if the comments below.

Oct 11 2012
Oct 11
Modules of the month story banner illustration.

Once again, I’ve surveyed the looong list of modules from the past month (September 2012). This article highlights and summarizes the features of some I found most notable. As usual, the selection and any opinions are my own and the order of appearance here is strictly alphabetical. Category terms are links to Drupal.org projects categorized with the terms. I’ve added terms for modules whose description lacked appropriate categories or might have been missing categories I thought were appropriate.

This month, while we didn’t get any new novelty modules which require bad judgment, there was one which I thought was funny and which otherwise serves no real purpose, other than perhaps to provide an example of object oriented PHP design with interfaces, etc: the module, written by Jess of University of Wisconsin-Madison and Drupal.org’s reigning IRC queen. Its very short (non)description is sure to make you smile:

Q: You’re a vegetarian; why do you get to have the blt project namespace?

A: The BLT is actually a base implementation; a properly architected interface does not mandate bacon.

Now let’s get on to the serious modules…

*/ Apache Solr Exclude Node

Categories: Search

The module, by Jens Beltofte of Propeople, helps to exclude individual nodes from Apache Solr, which can be useful when you have indexed a specific content type, and want to exclude a few nodes of that type. A checkbox, “Exclude from Apache Solr” is added to the node edit forms for selected content types. It requires Apache Solr Search.

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Apache Solr Field Collection

Categories: Search

The module, created by David Rothstein of Advomatic, allows content stored within a Field Collection to be indexed by Apache Solr search as part of the entity that the field collection is attached to. Enabling the Facet API module allows fields attached to the field collection to be available to add as search facets.

Status: There is an alpha release available for Drupal 7.

Architecture

The module, by Sheldon Rampton of DrupalSquad, provides reports documenting how your Drupal site is architected. These reports include “Site Entities”, which lists all content types, taxonomies, and other Drupal entities that have been defined for your website with a list of all fields for each fieldable entity; “Site Taxonomies” lists all taxonomies and their associated terms; and “Site Variables” lists all variables and their values. The purpose of this module is to provide some easy-to-read documentation of how your site is put together.

It looks like there are a number of other interesting features in the development roadmap, but this already looks very useful for documenting the way a complex Drupal project is put together.

Status: There is a development release available for Drupal 7.

Attribution

The module, written by Marcus Deglos of Techito, adds configurable attribution text at the bottom of your site content’s body field, so that if it’s scraped, attribution will normally be included.

Status: There is a development release available for Drupal 7.

Better 404

The module, contributed by Yvan Marques, is based on an article from A List Apart. It aims to provide more useful information when a visitor reaches your 404 page.

Status: There is a stable release available for Drupal 6. This looks very promising, so I’m hopeful there will also be a Drupal 7 release and that perhaps functionality like this could be part of Drupal 8 “core”.

Commons Like

The module, by Ezra Barnett Gildesgame of Acquia, allows users to “like” content and comments using the Commons “Like” widget and the Rate module and VotingAPI and has a stated goal to be expanded to be useful on sites that are not on the Drupal Commons distribution.

Status: There is a development release available for Drupal 7.

Commons Radioactivity

The module, also contributed by Acquia’s Ezra Barnett Gildesgame provides integration with the Radioactivity module to help identify the most active content and includes Views displays to accelerate the site-building process.

Status: There is a development release available for Drupal 7.

Conditional Flags

The module, coded by Sebastian of Taller, provides additional API features for the Flag module, for custom conditions between flags, so that logically, if, when one flag is set, another flag should be unset, this can be done automatically. There are also plans to build a user interface for site builders.

Status: There is a beta release available for Drupal 7.

Content Tab

The module, coded by Ashish Thakur of Srijan Technologies, India, makes it easy for site administrators or other users with appropriate permissions to view the content written by a particular user; it provides a page with sub-tabs for each content type created by a given user and a tab on each user page which lists all content written by that user and eliminates the need to build up this kind of functionality with Views. It also provides a admin UI to configure various display options, among other features lacking in the core “Tracker” module.

Status: There is a stable release available for Drupal 7.

Context Get

The module, created by Peter Vanhee of Marzee Labs, provides a Context condition plugin for $_GET arguments. It allows you to activate contexts with arguments like local?context=home or local?context=pro and was created to fill a feature request for Context.

Status: There is a stable release available for Drupal 7.

Deploy Services Client

The module, by David Rothstein of Advomatic, provides a Services client which communicates with Deployment endpoints and helps perform other operations on the content which the Deployment module does not directly support such as deleting or unpublishing content on an endpoint. Note that this is an API for developers only; there is no user interface.

Status: There is a beta release available for Drupal 7.

Drush Permissions

Categories: Drush

The module, created by Klaas Van Waesberghe of dotProjects, enables Drupal site administrators to easily query user permissions from the command line. It can display reports of all permissions with module and role filters, identify if a user has a given permission, or list all roles a permission is assigned to. It is not actually a module (but I’ve included it here since, like Drush, it’s on Drupal.org as a module and looks pretty darn useful). It should not be installed as a module, but as a Drush plugin, i.e. use drush dl drush_permissions to install, but from outside a Drupal root directory.

Status: There is a development release available for Drupal 7.

eKaay - QR Code Login

The module, written by Daniel Wehner of erdfisch, allows users of a Drupal website to log into their accounts by scanning a QR code on the PC screen with a smartphone, thus streamlining the login process for users on devices where entering username and password tends to be less convenient.

Status: There is a development release available for Drupal 7.

Facetapi Multiselect

Categories: Search

The module, another contribution from David Rothstein, provides a multiselect widget plugin for the Facet API module which allows faceted searches to use a multiple select dropdown for drilling down into the search results. It’s primarily designed to help integrate faceted search with JavaScript plugins such as the jQuery UI MultiSelect Widget (where this module has primarily been tested), jQuery UI Multiselect, and Chosen.

Status: There is a beta release available for Drupal 7.

Field Orbit

The module, coded by Elliott Foster of Four Kitchens, provides an Orbit slideshow display mode for image fields and field collections with images and much of it is a Drupal 7 port of the Field Slideshow module.

Status: There is a stable release available for Drupal 7.

Field UI permissions

The module is yet another coded by David Rothstein. It provides independent permissions for managing fields attached to each type of entity so that you could, for example, give an “administrator” role permissions like “administer users” and “administer taxonomy” but reserve the rights to modify the underlying field structure for a “developer” role. This could certainly be handy for complex use cases.

Status: There is a beta release available for Drupal 7.

Godwin's Law

The module, by Tobby Hagler of Phase2 Technology, is helpful for managing online forums and allows you to automatically moderate threads and close the discussion when certain keywords are found. By default, the module is set to close comments when Godwin’s law is invoked, but other keywords can also be used as triggers.

Status: There is a stable release available for Drupal 7.

Hide Site

The module, developed by Barry Fisher of Real Life Design, provides a way to practically hide a particular version of a site from search engines even though it’s on a publicly-available development server without needing to patch your .htaccess or robots.txt files. Getting into the particulars of how it works is beyond the scope of this article, but it’s fairly simple to configure and should help keep a site out of the public eye until you are ready to officially release it.

Status: There is a beta release available for Drupal 7.

highlight js

The module, contributed by Juned Kazi of ICF International, integrates the highlight.js library to provide language-appropriate syntax highlighting for code examples on your site. It automatically detects the language, but you can also set the language for any block of code to ensure correct behavior. Of course it depends on the Libraries API highlight.js library, installed per the directions in this module’s README.txt file.

Status: There is a development release available for Drupal 7.

Image Field Cross Slide Slideshow

The module, created by David Whitchurch-Bennett of Drupology allows images uploaded into an image field to be displayed with the jQuery Cross Slide plugin as a display formatter for the image field within the “Manage Display” settings of your content type.

Status: There is a development release available for Drupal 7.

Image link to preset

The module, written by Gabor Szanto extends on the two core-provided options for setting link for an image field (i.e. “link to content” and “link to file”) to also allow you to link to any image preset for the image. It requires the Field formatter settings API module and definitely looks useful for many use cases involving sites with images.

Status: There is a development release available for Drupal 7.

Image or Video field formatter

The module, developed by Chris Cohen of Tigerfish Interactive, adds a field formatter for a media field that can either be an image or a video and allows for separate thumbnails depending on whether an image or a video is displayed, e.g. so that you can show a “play icon” over thumbnails for video. The shadowbox Javascript library is used to display the full image or video when the thumbnail is clicked. The media module is normally used in conjunction with this, but other configurations are possible. Setting this up is non-trivial and the full details from the module description and README file should be consulted.

Status: There is a stable release available for Drupal 7.

Live Feedback

The module, written by J. Renée Beach of Acquia, is similar to Google+’s feedback system; it leverages the html2canvas library to allow users to quickly report issues to site maintainers from within the context of the page where the issue occurred. By making it easier for users to report issues with all the detail needed for developers to replicate and resolve them, this module helps ensure that issues do get reported and resolved.

Status: There is a development release available for Drupal 7 and given that Acquia is behind this work, we can hope that Drupal 8 might actually include such functionality in core.

Masonry

Masonry is a dynamic grid layout plugin for jQuery. Think of it as the flip-side of CSS floats. Whereas floating arranges elements horizontally then vertically, Masonry arranges elements vertically, positioning each element in the next open spot in the grid. The result minimizes vertical gaps between elements of varying height, just like a mason fitting stones in a wall.

The module, written by Peter Anderson of PackWeb, makes the jQuery Masonry plugin available to Drupal as a library. It contains sub-modules for integrating with fields and Views; its field formatter allows you to display multi-value fields in a Masonry grid layout and integrates with existing formatters so existing formatter-specific options, e.g. Colorbox settings, are retained. It currently supports the field types: image, “long text” and “long text with summary”, and like most modules which integrate a Javascript library, it relies on the Libraries module. The Field formatter settings module is also required for the Masonry field formatter and of course Views is required for Masonry views. Add the Masonry javascript and configure according to the directions on the project page.

Status: There is a development release available for Drupal 7.

Memory profiler

The module, written by Tim Hilliard of Acquia, logs peak PHP memory usage to the Drupal watchdog and is light-weight enough it shouldn’t add to the memory errors you would be trying to resolve when you activate it. It can be used in a production environment, where enabling Devel would not be appropriate. Knowing this is available when we need it will make all Drupal developers sleep easier.

Status: There is a stable release available for Drupal 7.

Mobile Switch Block

The module, coded by Siegfried Neumann, extends the Mobile Switch module with a theme switch block with links to manually switch between your mobile or desktop theme and is compatible with Mobile jQuery. Of course it requires Mobile Switch (version 7.x-1.4+) and Respond.js is recommended. The block could be especially useful for people testing the site, but can also provide better options for users of mobile devices who might, for whatever reason, prefer to use your site’s desktop theme rather than the automatically-selected mobile theme.

Status: There is a beta release available for Drupal 7.

Mozilla Persona

The module, coded by Daniel Pepin of Digital Bungalow, adds Mozilla Persona functionality to your site so users with a Persona account can authenticate without need for a site-specific password; you can still require registration. It should nicely enhance the usability of most sites which require login. It depends on the Session API module.

Status: There is a beta release available for Drupal 7.

Panels Ajax Tabs

The module, developed by Patrick Hayes of HighWire Press / Stanford University, provides the ability to have a tabbed panel-pane that displays mini-panels within it and allows you to pass context from the “master” panel to the mini-panels via AJAX.

Status: There is a development release available for Drupal 7.

Password Field

Categories: Fields

The module, created by James Sinclair of OPC IT, provides for creating fields that store passwords, stored in encrypted format and (by default) will not display them on the website. This is useful, for example, if you are creating a website that integrates with other services and you would like users to be able to store their password more securely than using a text field, so could certainly be useful in unusual use cases. That said, the module description also bears a strong reminder not to use this module if you have any alternative.

Status: There is a beta release available for Drupal 7.

Passwordless This is still an experimental module, and using it on production sites is not recommended.

The module, written by Antonio Savorelli of Communikitchen, provides a replacement for the standard Drupal login form to allow logging in without using a password. Instead, every login is done via a “one-time login” link, as if the user had forgotten their password. This could be useful on sites where users are not expected to log in very often, but there are still a few things about the way this works that makes me nervous; e.g., currently you need to confirm a change of email address at the new address, but not at the old address, which would make it simple for someone who jumps on your computer, while you are logged in and your back is turned, to take over your (Drupal site) account. That said, as it’s still considered experimental and not for use on production sites, we can hope such issues are addressed by the time this module is released as “stable”. Once that’s true, I can certainly imagine using this for some sites.

Status: There is a development release available for Drupal 7.

PDF Archive

The module, authored by Brian Gilbert of Realityloop, allows you to generate PDF archives of any entity; generation is triggered by Rules actions and you can configure the entity view mode and role of the simulated user for each rule. It includes a Feature as an example for configuration and otherwise requires the Libraries API module, with TCPDF library installed, and the Rules module.

Status: There is an RC release available for Drupal 7.

Permissions per Webform

The module, written by Daniel Imhoff of UW-Platteville, lets you set standard (normally global) Webform permissions for each individual Webform, e.g. “Access webform results”, “Edit all webform submissions”, “Delete all webform submissions”, “Access own webform submissions ”, etc. It adds a “Permission settings” fieldset tab to each Webform node.

Status: There is a development release available for Drupal 7.

PixGather

The module, developed by Mike Kadin of Merlin Education, is a Drupal Module and PhoneGap application that allows users to easily upload photos to your Drupal site. It was developed so that guests at a wedding could share their pictures, but it’s suitable for a variety of use cases. Currently, the mobile app part of this is only for Android, but an iOS version is planned.

Status: There is an alpha release available for Drupal 7.

Plugin tools

The module, written by Chris Skene of PreviousNext, allows developers to browse the various plugins provided by different modules, information normally hidden in the code. The Drupal 7 versions supports Chaos Tools plugins, but it’s possible that a Drupal 8 version will work with “core” plugins. See the project page for more details, but this definitely looks useful for developers working with cTools.

Status: There is a beta release available for Drupal 7.

Render As

The module, by Stuart Clark of Realityloop, allows you to see page elements as they will be displayed to various users or roles without needing to switch users. Using it is not easy to succinctly summarize, so you should check the project page for directions, but this definitely looks like a useful project for developers and site builders.

Status: There is a beta release available for Drupal 7.

Resumable Download

The module, authored by Sina Salek adds support in Drupal for resuming incomplete downloads, which could be very useful for users on slower connections or for larger downloads and provides a number of useful configuration options.

Status: There are beta releases available for both Drupal 6 and Drupal 7.

Session Cache API If you are not a Drupal programmer, then you may stop reading now. Just enable this module if another module tells you to.

The module, written by Rik de Boer of flink, is a simple two-function API for programmers to cache and retrieve pieces of user/session -specific information, and works well even with anonymous users in a cached environment. It is not for caching large amounts of information or content, nor should it be used for anything sensitive, but definitely looks interesting as a replacement for the $_SESSION variable, which may not an option with Varnish or similar caching engines. Developers who find this short summary of interest should definitely read the directions on the project page because using this is not exactly trivial.

Status: There is an alpha release available for Drupal 7.

Session cookie lifetime

The module, created by Kornel Lugosi of Pronovix, provides an admin interface for setting the lifetime of the session cookie. This could definitely be useful for sites where convenience is more important than absolute security.

Status: There is a stable release available for Drupal 7.

StatsD

The module, developed by Owen Loy of Acquia, provides Drupal integration for StatsD and is intended for sites that have an existing StatsD / Graphite setup. It’s preconfigured to send statistics for Watchdog entries, user logins, page views, and active user sessions, but developers can also configure it to send custom statistics. It definitely looks useful.

Status: There are beta releases available for both Drupal 6 and Drupal 7.

Suggested Modules

The module, written by Kevin Quillen of Inclind allows module maintainers to enter a “suggests” property to their module info file, with a link to a relevant module project page. This is a step down from “required” modules; it simply suggests other modules one might normally wish to use in conjunction with your module. Of course, for this to work, modules both need to have “suggests” entries on their .info pages, and users need to have this module installed and enabled. I think this is a great idea and could well be an improvement in “core”; otherwise, until it’s widely used by both site builders and coders, it won’t be very useful. Actually, combining this with Module supports (which still needs a Drupal 7 release) is a more likely future development; in any case it would be helpful if we got such functionality into Drupal core.

Status: There is a stable release available for Drupal 7.

System Status AJAX

The module, contributed by Chris Pliakas of Acquia, a small module which loads the system status check via AJAX so that the admin/config page is rendered more quickly, even when some of the status checks are delayed. Nice! I’m hoping this functionality is going into the System module in Drupal 8; in the meantime, this should definitely improve the user experience for Drupal 7 site administrators.

Status: There is a stable release available for Drupal 7.

Textbook

The module, coded by the prolific Bryan Ollendyke, of Penn State University as part of the ELMS Initiative, provides Features which include CSS styles, WYSIWYG settings, and CSS3 page templates to help any theme provide consistent textbook styling for the production of online course materials. Users don’t need to be expert in CSS / HTML, but even experts should find this helps streamline their development. If you are producing an online learning site, this module, along with many others by this fine contributor, should be very useful.

Status: There is a beta release available for Drupal 7.

Timezone Picker The timezone picker module from Nate Haug.

The module, written by Nathan Haug of Lullabot, provides a JavaScript-based timezone picker to replace the default Drupal timezone list with a clickable world map to select a user’s timezone and Geolocation support for compatible browsers, so setting a timezone is greatly simplified. Enabling it replaces the default timezone list on the site’s “Regional settings” page and user profile pages. All Javascript is included; no libraries need to be downloaded and quicksketch also wrote this to be mobile-friendly. Very cool!

Status: There is a stable release available for Drupal 7.

Typo The Typo module’s user interface

The module, developed by Roman Arkharov, provides a simple way for site visitors to report typographical errors in your site content; all they need to do is select text which includes a typo and press Ctrl + Enter to automatically notify the site administrator. It includes preset Rules events you can use, as well as Views for administrators to see a list of reported typos, among other useful integrations. This could definitely be worth checking out.

Status: There is a development release available for Drupal 7.

Views fields combine

The module, contributed by Stefan Borchert of undpaul, allows you to combine the output of Views fields, separated by any desired custom text. Normally you would do this with "Global: Custom text", however if one field is optional, your output would include an unwanted separator. Once this module is enabled, you’ll have access to a new field type, "Global: Combined fields", where you can select the fields you would like to combine.

Development on Views fields combine is sponsored by undpaul.

Status: There is a stable release available for Drupal 7.

Weather block

The module, developed by Antti Alamäki of Soprano Brain Alliance, provides blocks and pages in which you can display forecasts from Yahoo Weather, World Weather Online, or weather.com and may include additional future service integrations. Drupal 7 needed more support for weather forecast integration, so it’s good to see this and I’ll certainly be giving this a try on sites where I might want a Weather block.

Status: There is a stable release available for Drupal 7.

Sep 26 2012
Sep 26

If you need to make price increases when specific attributes or options are selected on products, hook_cart_item() may be able to help you out.

My Drupal 6 Ubercart Dilemma

In a recent situation I needed to create an attribute that contained a price. The trick here is that the price increase needed to be added based on the value selected in another corresponding attribute.

In this example I had one Drupal 6 Ubercart select attribute that was essentially serving the role of a quantity option (I had the traditional Ubercart quantity field disabled). The reason this was set up this way was because this product basically came in packages of select quantities. So the Ubercart attribute had dropdown options of lets say 10, 25, 50, 100, etc.

I had another Ubercart attribute that was created as a single checkbox with a price increase of $0.50. The trick here, was this price increase needed to be based on the quantity dropdown of the number of items in the package.

Drupal Ubercart Attribute Example

This might be a little confusing so I will try to explain it in an example.

  • User goes to the product page
  • User selects quantity if 25, the price of this is $50
  • User selects the single checkbox to trigger the $0.50 price increase per item, the price is now $62.50 ($0.50 x 25 items in the package plus the original $50)

The hook_cart_item implementation

In this example I am just using hard-coded attribute values and option values. Keep in mind this should probably be avoided if possible, but because this was such a unique situation that only occurred for these attributes, I used the hard-coded values for simplicity. This could easily be abstracted into a separate module with an administration interface.

/**
 * Implements hook_cart_item().
 */
function MYMODULE_cart_item($op, &$item) {
  switch ($op) {
    // We only care about the "load" operation, in which a cart item is 
    // being loaded.
    case 'load':
 
      // Here is where I set the hard-coded values for the attribute 
      // and option ids. These values can be pulled from the 
      // Ubercart attribute database tables or from the URLS in the 
      // Ubercart attribute administration pages.
      $quantity_aid = 13;
      $checkbox_aid = 12;
      $checkbox_oid = 50;
 
      // A variable to keep track of the price increases.
      $price_increase = 0;
 
      // Add price increases for my attribute (aid=12, oid=50).
      if (isset($item->data['attributes'][$checkbox_aid][$checkbox_oid])) {
        // Load the attribute so we can determine the price per item that 
        // should be added.
	$checkbox_attr = uc_attribute_load($checkbox_aid);
 
        // Pull the price value (in this case $0.50) from the attribute.
	$price = $checkbox_attr->options[$checkbox_oid]->price;
 
        // Check if the quantity attribute has a selected option value.
        if (is_numeric($item->data['attributes'][$quantity_aid])) {
          $oid = $item->data['attributes'][$quantity_aid];
 
          // Load the attribute so we can pull out the quantity value of 
          // the dropdown.
          $attribute = uc_attribute_load($quantity_aid);
          $quantity = $attribute->options[$oid]->name;
 
          // Make sure the quantity is in fact a numeric value.
          if (is_numeric($quantity)) {
            $price_increase += $price * $quantity;
 
            // Because Ubercart will automatically add the original 
            // attribute price to the total, we need to then subtract out 
            // the original added price.
            $price_increase -= $price;
          }
        }
      }
 
      // Add the price increase to the cart item.
      $item->price += $price_increase;
      break;
  }
}

In the example above, you will need to replace the attribute ids (aid's) and the option id (oid) based on your attributes. You will also need to replace "MYMODULE" with the name of the module you are placing this code in.

Hope this helps someone in a similar situation. If you have any questions or know of a different way to do this, let me know in the comments.

Sep 24 2012
Sep 24

What with this being a library and all it became necessary to get a document management solution rolling.  Initially looked at  File Depot and may go back to that again, however it wasn’t working cleanly out-of-the-box… the desktop integration though may bring it back…  Also I really like PlUpload for its HTML5ness and potential to work on iOS devices, however it doesn’t mesh with CKEditor – our WYSIWYG of choice, and that’s a major requirement.

So without further ado…

webfm tools

webfm tools

Set up default directories and such

Set up default directories and such

Configure the wysiwyg editor

Configure the wysiwyg editor

Open up the webfm module

Open up the webfm module

The webfm module in action

The webfm module in action

Sep 13 2012
Sep 13

CCK Signup is a fun module that is very drupal in the sense that it really just extends a bunch of modules you may already have.  Here’s a brief tutorial on using Rules to handle some basic notifications.  Say you want to know when someone has dropped a class.

 

Your initial rule conditions

Your initial rule conditions

  1. get a new rule set up and set the initial condition to be “After deleting content”
  2. Set the next condition to be “content has type”
  3. Select the signup type of content
  4. Lastly choose to send an email to an arbitrary email address – in this case let’s say it’s you, the webmaster
  5. Send the email.  Thanks to the Tokens module you can reference content from the fields in the deleted content Using tokens in the emails

    Using tokens in the emails

    Send an email to an arbitrary email

    Send an email to an arbitrary email

    select the type of content

    select the type of content

    Content has type as condition

    Content has type as condition

Sep 13 2012
Sep 13

Welcome to another Daily Dose of Drupal. This is episode number 6 and today we’re going to be talking about the Drupal Field Group module. But first off; if you’re not following me on Twitter, you can do so @smthomas3, if you’re interested and also if you haven’t already subscribed to the codekarate.com newsletter. What I’m thinking of doing is rolling this Daily Dose of Drupal videos up or at least the concepts in maybe once a month give or take, posting a longer 20 to 30 minute video going into a little bit more detail in specific topics and case studies with Drupal and only members of my site and newsletter will be able to get to that but it’s free so go ahead and sign up.

But today as I mentioned we’ll be going over the Field Group module and if you’ve used Drupal 6 CCK, it’s going to be pretty familiar but a few things that are different and a few new features so I’m just going to go over this pretty quickly. I have a test site here; I’m going to go ahead and download the Drupal 7 Field Group module and I’m going to enable it, it says it was enabled successfully so I’m going to jump back in here and we’re just going to create a new content type and we will call this Content Type “Doctor Appointment”, keep all the rest of the stuff pretty much standard and we’ll just go ahead and save it. We’ll go ahead in our Doctor Appointment content type, we will go to Manage fields, you’ll see now it looks a little bit different, you have this new Add Group section down here and the Field Group section.

So let’s go ahead and let’s say we want a new group called Patient Information and this maybe isn’t the most accurate example of how you use it but there’s a whole bunch of uses. I’m sure you can use figure out a bunch of ways that it will be useful. And so you can break this up into a Field Set, Vertical tabs, Horizontal tabs, so there’s a whole bunch of different options. So we’re going to go ahead and go to Horizontal tab item and we’ll just save that and we will add a field called “First Name” … that’s an existing field, we want a new field, sorry about that; First Name, so I’m going to create a new field, we’ll make this Text, go ahead an scroll down to the bottom and click Save and leave everything else default, just keep it simple and we’re going to actually drop that into Patient Information, we’ll hit Save and let’s go ahead and add another group called Appointment Details and we’ll also make this a horizontal tab item, I’ll save that and we’re going to then say under this one we’re going to want Appointment Date, make it a date and we’ll have it a pop-up calendar and you’re going to need the Drupal Date module installed if you don’t already have it in order to get this date go up but this site already had that so we’re going to go ahead and say we just want Year, Month, Day, Hour and Minute, we’ll use the Drupal website’s time zone, we’ll go ahead and collect an End Date as well and we’ll go ahead and Save that, leave the rest of the defaults there and we will drop that Appointment Date or Appointment Details into there and we’ll also drop the Body into there as well.
And now we’re going to go ahead and actually add some of this Doctor Appointment Content; you’ll see now we have a couple of different tabs here that expand, you can add the first name for Patient Information or you can add the Appointment Date or Body Field.

But let’s go back into the structure and let’s change a few other things; I’m going to add a group fro just Appointment and I’m going to make this a Horizontal Tabs Group and inside here I’m going to actually drag in these Horizontal Tab items to actually get them working correctly.

And now assuming I saved it I go back and now I have a little nicer looking Horizontal Tabs. So you can see there’s a whole bunch of different options that you can use in order to layout your Note Edit forms to make them easier not only for you to enter information but if you’re building the website for someone else for someone who’s not necessarily a developer to easily enter various contents into your website. And we’ll just go back and look at a couple of other options here; so we could also then change this to an Accordion group and change this to an Accordion Items and save this. And you can of course go ahead and try a whole bunch of other ones out but we’ll just go to a couple here and now you can see a little bit different formatting; same concepts but just puts the different fields into the different buckets and allows you to more easily add content to your site.

We just kept it simple today. Tomorrow I’ll be going over on a whole new concept but again follow me on Twitter if you’re not already and hopefully you learned something today. Thanks for watching.

Sep 12 2012
Sep 12
Modules of the month story banner illustration.

There are tons of new Drupal modules that got released in August; almost 200 module project pages were created. Some of them aren’t listed here because they currently have no release; some don’t even have code (yet). But a lot of very promising modules were released in August, perhaps due to the extra community involvement around DrupalCon Munich. There were even a couple novelty modules, good for a laugh if not much else: the Honey Badger module (“Honey badger don't care. Honey badger always clears cache.”), contributed by Camilla Krag Jensen of the Danish news site, Dagbladet Information, is one such module worth looking at if you need something to make you smile. The module, by Sally Young of Lullabot, “randomly swaps values of the variable table around.” Well, maybe it would if there were actually any code behind the project. Both require Bad Judgement. I suppose the latter project page could have been created for a new Lullabot training, but I’m curious what inspired Ms Jensen. Anyway, the women of Drupal came through with some laughs.

A more useful looking set of modules was also released in August by French developer, Guillaume Viguier-Just: The module is required for any of its related modules, which include Base Page, Base Article, Base Link, Base Media, and Base Apps. These modules are “… meant to be a set of features that will provide the "lowest common denominator" for building Drupal apps and distributions.” The Base modules depend on Apps Compatible, another new module from August which I think will be in very wide use before long (Apps Compatible is covered below). There are also a couple new modules for the Spark distribution (listed below), several new Drush extensions, and a number of other modules which look good for boosting developer/themer productivity.

As with previous editions of this article, all modules are listed in alphabetical order. If categories were missing on the Drupal.org project page, I’ve added appropriate categories. Additional caveat: I have not tested all of these modules and have not fully tested any of them. They are new modules and some come with new bugs, so beware.

*/ Anonymous login

The module, authored by Mike Stefanello and sponsored by Workout Spots, provides a login page with redirect to the originally requested page if an anonymous visitor to your site follows a link which requires higher privileges. The example use case is your site sends out emails with links which require a user is logged in; but subscribers to your email list get an “Access denied” when following the links (if not already logged in); a usability nightmare. Anonymous login to the rescue! Very nice.

Status: There is a stable release available for Drupal 7.

Apps compatible As well as providing methods for shared components, Apps compatible includes a collection of methods handy for developing interoperable features and apps.

The module, by Nedjo Rogers, is already reported in use on 278 sites, which shows there must be a use case for this module that was only released a month ago; I anticipate a lot more sites will be using it shortly. It helps alleviate compatibility issues between different Apps and Features caused by conflicting dependencies, etc.

Status: There is an alpha release available for Drupal 7.

Backup and Migrate SFTP

The module, by Chad Robinson, extends the very popular Backup & Migrate module with SFTP, instead of simply FTP when setting up “Destinations”. This is a GoodThing™ for security. I’ll definitely be keeping an eye on this.

Status: There are dev releases available for both Drupal 6 and Drupal 7.

Better Statistics

The module, authored by Eric Peterson of Tableau Software, extends the core Statistics module and collects additional data such as cache status and user agent without adding a lot of extra performance overhead. This could certainly be useful.

Status: There are stable releases available for Drupal 6 and 7.

Block Upload

The module, created by Alexander of ADCI, LLC, provides a simple block with an uploader for the node being viewed, so users who don’t have full “edit” permissions for the content can still upload files and images (or if all you want to do is upload a new attachment, you don’t need to open the content in edit mode). Cool!

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Book Title Override

The module, written by Bryan Ollendyke of Penn State University, allows you to change the titles displayed in Drupal’s “Book” navigation so they don’t have to be an exact match to the constituent node titles. This eliminates one limitation that many might have been frustrated by.

Status: There are beta releases available for both Drupal 6 and Drupal 7.

Chamfer defaults

The module, also by Bryan Ollendyke maintains the default settings for the Chamfer theme, an Omega sub-theme with full HTML5 adaptive theme originally used for presenting online courses on the Penn State site (and another contribution from Ollendyke). It allows you to easily move defaults or your settings from one site to another.

Status: There is a beta release available for Drupal 7 and a development release available for Drupal 6.

Close Block

Categories: Content

The module, is another contribution by Alexander of ADCI, LLC. It allows users to close any block configured to be user-closable. Blocks can be configured to stay closed or reopen the next time a page with that block is displayed, be displayed a certain number of times before closing is permanent, or re-appear after a period of time. There are global settings, per-theme settings, and settings in the configuration for each block.

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Configuration Interchange and Management

The module, coded by Thomas Fini Hansen of Reload!, is the first module I’ve seen which works with the new Drupal 8 Configuration Management system. Of course it’s still early for Drupal 8, so it goes without saying that all features are experimental, but this is intended to provide a simple way to save snapshots of configuration settings, roll back to snapshots, and deploy snapshots from one site to another. This could find a place in core by the time of “feature freeze”.

Status: There is a development release available for Drupal 8.

Cron Cache

The module, written by Will Vincent of Marker Seven, allows individual caches to be cleared at configurable intervals.

Status: There is a development release available for Drupal 7.

CSS Flipper

The module, written by Tsachi Shlidor, can automatically create and maintain a “flipped version” of any RTL or LTR CSS code, which can greatly streamline developing and maintaining themes. Nice!

Status: There is a beta release available for Drupal 7.

Dev Tools

The module, produced by Yuriy Babenko of Suite101, is “a collection of PHP classes and functions which help with and simplify Drupal module development”. From the looks of things, this could well be useful, perhaps especially for debugging.

Status: There is a development release available for Drupal 7.

Disable "Language neutral"

The module, written by rysmax, allows you to show only a sub-set of otherwise-allowable language options for each content-type, which means you can remove such nonsense as “language neutral” from the selectable languages for a Blog entry… Nice and simple, and most content types on most multilingual sites would probably benefit from this.

Status: There is a stable release available for Drupal 7.

Dismiss

The module, produced by Chris Ruppel of Four Kitchens, allows you to “click away” Drupal messages so that they are out of your way without a page refresh. It’s a simple module with no configuration, but it could be handy for when you are documenting the steps of a process and end up with Drupal messages displayed that might distract from a screenshot.

Status: There is a stable release available for Drupal 7.

Drupal-up

The module, written by Kosta Harlan of DesignHammer, is “a Drush extension that facilitates building virtual machines for local development of Drupal sites.” It includes blueprints for virtual machines for hosting Drupal 6–8 -based sites. Looks interesting.

Status: There is a beta release available “for Drupal 7” (presumably, like Drush, the Drupal version is not really applicable).

Drush Hosts

The module, written by Christopher Gervais of Koumbit.org, provides Drush commands for managing /etc/hosts, so you can easily add and remove entries. This definitely looks useful.

Status: There is a stable release available for Drupal 7.

Drush Issue Queue Commands

The module, produced by Greg Anderson, is a Drush extension which includes commands which help manage a Drupal project issue queue, making things simpler for beginners and faster for everyone. I’m sold!

Status: There is a stable release available for Drupal 7.

Entity RDF

The module, developed by Stéphane Corlosquet, the primary maintainer of Drupal’s core RDF, is a replacement for Drupal core RDF, which provides tight integration between the RDF mappings and Entity API and attempts to solve shortcomings of the Drupal 7 core RDF module. This is worth keeping an eye on.

Status: There is a development release available for Drupal 7.

Feeds YouTube Fetcher

The module, contributed by Travis Tidwell of AllPlayers.com and sponsored by Anglican TV, is a YouTube feeds fetcher which is able to overcome the situation where feeds are paginated, thus getting all of the videos in a feed rather than just the first 50. This could well be useful.

Status: There is a development release available for Drupal 7.

Flag expire

The module, by Joachim Noreiko, can use either the Date or Time period module to create flags which can be active for a preset period of time or which begin/end at specified times.

Status: There is a beta release available for Drupal 7.

Flatfish

The module, developed by Mike Crittenden of Drupal Connect, uses the Ruby gem, Flatfish, to help scrape HTML data and import it into a Drupal site, useful, for instance when migrating an older website into Drupal. It includes other code to help with the migration of the data. I know there are other popular modules for this kind of task, but this could also be worth keeping in mind.

Status: There is a beta release available for Drupal 7.

Icon fonts Icon Fonts can easily be changed for color, size, drop-shadows and other effects

The module, created by Gábor Hojtsy of Acquia as part of the Spark distribution definitely looks interesting. Icon fonts allow you to easily change size, shape, color, strokes and other attributes. See this CSS Tricks post about icon fonts for an example of how useful they can be as a replacement for standard icons.

Status: There is an alpha release available for Drupal 7.

Image CAPTCHA Refresh

The module, produced by Dmitry Drozdik of VolcanoIdeas, helps with one of the problems of Captcha; if the image is “too easy”, bots can parse the Captcha—too hard and humans have a hard time and might need to refresh the page a few times, which can be a real hassle if they have completely filled out a form. This brings in a feature that is missing in some Captcha plugins: the ability to get a new Captcha without refreshing the whole page and should result in less frustration for users and a lighter load on your server.

Status: There is a stable release available for Drupal 7.

Leaflet More Maps The Stamen watercolor effect and Thunderforest cycling maps are both options with Leaflet Maps

The module, created by Rik de Boer of flink, expands your mapping horizons beyond Google maps, allowing you to include maps from a variety of alternative map providers, such as the watercolor-effect maps from Stamen or the trail and cycling maps from Thunderforest. As its name implies, it also depends on the Leaflet Javascript library.

Status: There is a beta release available for Drupal 7.

LGP

The module, which stands for “Lazy Guinea Pig”, created by develCuy and sponsored by dilygent, is another developer toolset which will help you debug your Drupal code. It can write to a temporary log file, works in places where Devel’s dsm() won’t, and has a number of other features that make me think this is worth knowing about. It also includes a number of Drush commands.

Status: There are development releases available for Drupal 7 and Drupal 8.

Logic Block

The module, produced by Pat Lockley, provides a number of configuration options for blocks to allow site administrators to easily perform such actions as merging blocks, replacing one block with another in particular circumstances (e.g. if one block is empty or based on language, role, user ID, etc), and other nifty tricks. I’ve only just experimented with it a bit, but it definitely looks useful.

Status: There is a stable release available for Drupal 7.

Mobile friendly navigation toolbar

Categories: Mobile

The module, produced by Gábor Hojtsy of Acquia, is another module developed and released as part of the Spark distribution. As the name implies, it provides a better toolbar for mobile navigation. Like the rest of Spark, it provides a way for us to test and use awesome new Drupal 8 features in our Drupal 7 projects. Very nice!

Status: There is an alpha release available for Drupal 7.

Module configure links Module configure links opens the config page for a newly enabled module

The module, by Brad Erickson of ChapterThree, helps solve a typical Drupal problem, especially common when working on sites with a lot of modules: you enable a new module, but then need to search around to find its configuration page. This module presents obvious links for configuring any modules activated, for a smoother Drupal site-building workflow. If only one module is activated, it automatically redirects you to the configuration page for that module. I’ve tried it, I like it, and I’ll definitely be using it on more than just my local “module testing” site.

Status: There are stable releases available for both Drupal 6 and Drupal 7.

OpenFolio Features OpenFolio is a distribution for photographers or other visual artists who want to create a web portfolio of their work.

The module, developed by Ted Bowman of Six Mile Tech, was released as part of the OpenFolio distribution, also released by Mr Bowman in August. it contains no custom code, but handy exported content types, Views displays, Panels, and other useful bits to help streamline the process of creating an online portfolio site to display visual art. Of course it depends on Features.

Status: There is a development release available for Drupal 7.

OpenLayers Filters

The module, by Pol Dell'Aiera, provides a text filter which replaces a token representing any OpenLayers map preset with the map, right within your content.

Status: There is a stable release available for Drupal 7.

Override css

The module, authored by Wim De Craene of Jeugdwerknet vzw, provides a simpler alternative to Sweaver or Livethemer which allows a client/administrator to make simple changes to site CSS, e.g. changing the color of H1 and H2 headings, through a simple UI, without even having to know any HTML or CSS.

Status: There is a development release available for Drupal 7.

Panels Extra Styles

The module, coded by Sean Dunaway provides additional region and pane styles for Panels with full HTML5 support. Since users are also encouraged to contribute their own styles, the options should increase with time. This looks well worth trying out if you are using Panels.

Status: There is a stable release available for Drupal 7.

Pathinfo

The module, authored by Cameron Tod of NBC Universal, is a Devel plugin which displays useful information about which module and function is responsible for the page you are viewing. It links the appropriate Drupal API pages, where applicable, and displays full Krumo output for page arguments. This looks handy for those times you need to fix some issues in a Drupal site, but have no idea where things are coming from.

Status: There are beta releases available for both Drupal 6 and Drupal 7.

Required by role Required By Role checkboxes on the Tags field configuration

The module, written by Alejandro Tabares, simply adds some extra checkboxes to each field configuration form so that you can not only specify that a field is required (for all roles), but can instead specify that a field is required only for particular roles. I suppose the use cases for this are not so common, but I’m sure I’ve had at least one situation where this would have been useful.

Status: There is a stable release available for Drupal 7.

Resolve IP

The module, by Yannis Karampelas of Netstudio, is simple, but very useful for understanding what’s going on in the system log (Watchdog) entries: it resolves the hostname for each IP address so you see (for example) crawl-66-249-66-212.googlebot.com alongside the IP address.

Status: There is a beta release available for Drupal 7.

Responsive Background Images

The module, is yet another contribution in the same vein as other modules recently released by Daniel Honrade of Promet Solutions. It provides a range of rules for background image sizes, which it loads based on the size of the browser window. Phones get a smaller background image than iPads, which get a smaller image size than a full-size browser window on an HD monitor. This, of course, helps conserve mobile bandwidth which helps make your whole site more “responsive”.

Status: There is a development release available for Drupal 7.

Search API Extended String Filter Did you ever want to be able to search partial string using the search API from within views, now you can, supports all the regular (exposed) filters and also 'Starts with', 'Contains', …

The module, contributed by Jelle Sebreghts of Attiks, enables searching for partial strings with the full Views search filters.

Status: There is a stable release available for Drupal 7.

Search API stats

The module, authored by Brandon Stone of ImageX Media, provides a block which allows users to see your site’s top search phrases. Of course there is a bit more to getting this working than simply adding and enabling the module, but for a search-related module, this looks relatively easy to get working.

Status: There is a stable release available for Drupal 7.

Searchcloud Block

The module, developed by Fabian de Rijk of Finalist, is similar to Search API Stats (above). Instead of a block with a simple list of most-searched terms, it provides a block with a “cloud” of those search terms.

Status: There is a development release available for Drupal 7.

Services Entity API

The module, created by Pedro Cambra of Commerce Guys, provides integration of Services and Entity API. It was developed with the needs of Drupal Commerce users in mind, but can be used for any Drupal entities.

Status: There is a development release available for Drupal 7.

Setup

Categories: Utility

The module, developed by Stuart Clark of Realityloop, gives developers and “adventurous site builders” a way to create a script for a client with a series of steps to enter their personal data (e.g. social networking accounts, Google Analytics tracking codes, etc); information which might not have been available during the development process.

Status: There is a beta release available for Drupal 7.

Simple Editor

The module, contributed by Ki H. Kim of Urban Insight, provides an almost-completely pre-configured WYSIWYG editor, based on TinyMCE. The aim is to give users a Wordpress-like, “ready-to-use”, editor, and not to be super-flexible, but if the common use case assumed applies to you, this could be a great time-saver.

Status: There is an alpha release available for Drupal 7.

Simple oEmbed

Categories: Media

The module, also by Ki H. Kim, integrates a simple setup of oEmbed with the Simple Editor, to make it easy to add videos and other rich media to content. Like the Simple Editor, it assumes a lot of the configuration, so for less typical use cases, you might want to use the full oEmbed project, which provides additional configuration options.

Status: There is a beta release available for Drupal 7.

Taxonomy Group Fields

, by Chris Albrecht of the National Renewable Energy Lab, is a taxonomy selection “widget” intended for larger vocabularies, currently those with two levels of hierarchy (parents and children, but no “grandparents” or “grandchildren”), however the project page indicates that there is an interest in expanding to multiple hierarchy levels, among a number of other useful features. Currently, if a parent is selected, all of its children are automatically included (parent acts as “select all” for children), but the developer also indicates he would like to provide this behavior as an option, rather than as the “only way”. This module is similar to one of my favorite, not-yet-for-D7 taxonomy selection/management tools, Taxonomy Super Select. What TGF lacks (a feature in TSS) is the ability to add new terms; I think it would be cool if it supported adding a new term into any group (with role-based limits on adding new terms). But there are so many use cases for Taxonomy widgets that it’s probably best to just create a limited module that does one thing well rather than trying to be everything for everyone.

Status: There is a development release available for Drupal 7.

Taxonomy Orphanage

The module, coded by Elliott Foster of Four Kitchens, is a module that helps resolve a rather painful bug in Drupal core. If you delete a taxonomy term, references to it still are retained in entities which used it. Taxonomy Orphanage provides interfaces for cleaning up such references. Nice work, Elliott!

Status: There is a stable release available for Drupal 7.

Theme Hider

The module, authored by Victor Quinn, provides a method for site administrators to hide particular themes on sites where users are allowed to select their preferred theme. Some enabled themes might only be for admin or for special purposes, so this is a good thing to have if you want your site to be displayed nicely for everyone.

Status: There is a stable release available for Drupal 6.

tinynav.js

The module is another contribution from Bryan Ollendyke. It integrates the tinynav.js jQuery library, which converts a typical list-based menu into a select-list drop-down if the browser window is narrow (e.g. on smaller displays). It’s extremely light-weight at only 362 bytes (minimized and gzipped). This module provides a number of configuration options and was designed for use with the Chamfer theme, but also should work well with other Omega-based themes (what it’s been tested with) and possibly other themes. Looks good!

Status: There is a beta release available for Drupal 7.

URL Alias Permissions

The module, written by Justin Phelan of Blackwood Media Group, “allows site administrators to set permissions to create and edit url path settings by content type”. This is certainly useful for particular use cases.

Status: There is a stable release available for Drupal 7.

User Import Framework Plus

The module, written by Deji Akala of JB Global, extends the User Import Framework to allow importing more than just the basic three fields (email, username, password) the UIF supports. This certainly looks like it could be useful.

Status: There is a development release available for Drupal 7.

Visual select file

The module, coded by Rudie Dirkx of ezCompany, is simpler than Media and easier to extend, plus it includes visuals (thumbnails) to help you select files. It uses Views and FileField Sources to help it work its magic. Nicely done!

Status: There is a beta release available for Drupal 7.

Webform Email Raw Emailing raw, unfiltered (filter_xss) data from a Webform submission can be risky, so only use this module if you absolutely require this behavior and understand the risks.

Categories: Mail

The module, contributed by Robert Bates of Phase2 Technology, provides a solution for sending raw, unfiltered XML from Webform submissions.

Status: There is an alpha release available for Drupal 7.

Webform Serial

Categories: Content

The module, developed by Peter Lieverdink of Creative Contingencies, simply “provides an auto-incrementing number field for webforms.”

Status: There is a development release available for Drupal 7.

WireDocs … a large legacy of documents in proprietary formats, such as MS Word or Excel, may discourage from moving to an online editor. Additionally, legal issues might arise if confidential files are hosted by a third party service provider.

The module, from Gottfried Nindl of OSCE, allows your Drupal site to host files in various office formats which can be opened (seamlessly downloaded and opened by a native, local application), edited, and saved (seamlessly uploaded back to the server) with a Java applet that bridges the gap between Drupal and the client operating systems. This looks like a pretty cool alternative to third-party document-hosting systems.

Status: There is a beta release available for Drupal 7.

Sep 07 2012
Sep 07

Drupal 8 Multilingual Initiative Code Sprint weekend

I took a train from Frankfurt (Germany) down to Munich the Saturday before the DrupalCon. When I joined the Multilingual Sprint on Sunday morning, many of them had already been sprinting for a full day and a number of issues were ready for review, so I dived in, observing the behavior of Drupal 8 before and after applying patches, proof-reading the patches for anything odd (e.g. typos in the documentation), discussing the issues in comments and in IRC with people who were sitting just across the room (other times actually speaking in person). By the end of the day, instead of the dozen or so people that Gábor Hojtsy, the Multilingual Initiative team lead, had expected, there were close to 50 people at the location, some joining us in the work on Multilingual issues, some working on other Drupal 8 tasks, and some who were just arriving in Munich and followed the Tweets to where we were. Luckily, the location rented for the Saturdays and Sundays before and after the DrupalCon week was big enough to accommodate all the extra arrivals.

While on the topic of the venue we used for those weekends, I’d like to personally thank Stephan Luckow and Florian (“Floh”) Klare of the Drupal-Initiative e.V. for all that they did to find a nice place that would still leave us with a budget for food and for their valiant work on stretching the food budget while still serving up excellent fare, in keeping with the fantastic meals we enjoyed the rest of the week. Instead of ordering delivery, they prepared almost everything themselves, including beautiful open-face sandwiches, fruit platters, and lovely grilled specialties at a club we went to where you can barbecue in the Biergarten.

…thanks for the huge help to the local organizers, especially Florian Klare and Stephan Luckow. They helped us manage collecting and spending sponsor money wisely with the Drupal Initiative e.V, prepared great sandwiches and fruit plates for us and even organized a sprinter party night with grill food. It was amazing to work with such helpful and flexible local organizers.
Gábor Hojtsy, September 5, 2012

Luckow and SirFiChi of the Drupal Initiative, organized the location and made us great food!

Since people were “fresh”, I think a lot of work got done on the first weekend and the Monday before the conference (more than 50 people joined us and worked on various core initiatives on Monday in the room we later used for core most conversations at the Sheraton), which also meant that issues were still fresh in our minds while we had days of sessions and conversations, so when we started sprinting again on Friday we had lots of new ideas for the tasks we were still working on. Friday’s sprints were at the Westin Grand, where there was great attendance both upstairs in the main room as well as a large room downstairs from it, where Drupalize.me hosted a core contribution workshop to ease people into the process of contributing to core. I decided to go to that workshop since I’m still pretty new to it all and found a few people sitting nearby who were I was also able to interest in some Multilingual tasks, so while the main group sprinted upstairs, we also worked downstairs. Later on, I came upstairs, and since there were not a lot of simpler tasks for “core newbies”, like myself, I took some time to sprint on a module I contributed some time back, before there was much of anything for Drupal 7 in the area of “multilingual”… and tried to make my module more multilingual-friendly. I got a few good commits and a new release out for Internal Links and also recruited a colleague to look at the code with me, provide some ideas, and become another maintainer. So I personally found Friday quite productive.

*/ First off, a sprint on this scale would not be possible without sponsors and significant on-site help. DrupalCon provided us with space on Monday and Friday, and some great food on Friday. The rest of the days would not have been doable without comm-press, dotProjects.be, Open8.se, OSINet and Acquia. The [ … ] financial sponsorships they provided paid for our weekend venue [ … ].

I continued sprinting with the Multilingual initiative at the Film Coop Saturday and Sunday, leaving mid-afternoon on Sunday to get back to the train station. When I left the other sprinters, Webchick was only finally getting some rest after her trip home and we had about 20 issues that were marked “RTBC”. In all, there were dozens of issues tackled over the weekend. For a complete overview of all the issues we made progress on, see Gábor’s post about the sprints, where you can also check out his excellent DrupalCon core conversation presentation, “Drupal 8’s Multilingual Wonderland”. There is still a lot to do in the time between now and the “feature freeze” deadline, but we made good progress in the DrupalCon sprints, so hopefully we can push on and get the rest of the critical tasks done in the time remaining.

One of the less trivial tasks I took on during the final sprint weekend was documenting the new language_select field type, which involved checking out the Drupal API (documentation) project, updating the Form API table to include a new Element column (language_select) and Property row (#languages), as well as information about these (below the table) and linking them in all the appropriate places. Currently, updating this page is a bit of a pain, but hopefully we will move to a better system for maintaining this information, perhaps even automated generation. While I’d worked on other Drupal documentation pages before, this was the first time I’d actually contributed patches to update the API, so it was a good learning experience.

If you’d like to help out with the Multilingual initiative or other core contribution, you might first want to take a look at the Drupal 8 Initiatives page, where announcements about coming IRC meeting can be seen. This page also has links to the news, roadmaps, filtered issues, and other pertinent information. Drupalladder.org is also a great place to go for lessons to help you work through the steps of being ready to contribute to Drupal core.

I look forward to seeing you all in IRC and in coming code sprints.

Aug 29 2012
Aug 29

So are you? You probably are, the function's been around for a while. But it's okay if you aren't. I wasn't for the longest time. But now I am, and so should you. 

So what does it do? Well, somewhat surprisingly, the documentation explains it quite well:

"menu_get_object() provides access to objects loaded by the current router item. For example, on the page node/%node, the router loads the %node object, and calling menu_get_object() will return that."

Before I knew about menu_get_object(), I was naively using the following code in my themes and modules to load the current page's node object:

if (arg(0) == 'node' && is_numeric(arg(1)) {
  $node = node_load(arg(1));
}

But now, I can just do this:

$node = menu_get_object();

Cleaner, right?

Also, it has the added bonus of being able to load any object loaded by the current router item. Nodes are just the default. Try it with users, taxonomy terms or even comments. Just remember you have to specify the type of the object and the position of the object ID in the path if you're loading something other than nodes.

$user = menu_get_object('user', 1);

A closing note: This function was actually introduced in Drupal 6 and it was recommended that you use it because the objects returned by menu_get_object() were statically cached by a function it used, menu_get_item(). However in Drupal 7 all entities, including nodes, are statically cached so the performance boost you used to see from menu_get_object isn't really there anymore.

I still think it's neat though and I'm going to keep using it anyway.

Jul 17 2012
rmo
Jul 17

Hello, Shadow is here!

Posted on: Tuesday, July 17th 2012 by Richard Mo

Have you ever felt that doing front-end web development for mobile web devices (i.e. Android, iOS) is a real pain, especially when you can’t do any inspections quickly? Designers or Themers would totally agree with me on this. Web developers, in general, would feel the same way but not as much as designers/themers do. And how about QA in general – manually pressing links or refreshing pages? It’s a lengthy process… Now, may I suggest to you that it is possible to shadow your actions across multiple devices?

I’ve recently been introduced to Adobe Shadow which addresses all the pain I mentioned earlier. A quote from Adobe Labs:

“Adobe® Shadow is a new inspection and preview tool that allows front-end web developers and designers to work faster and more efficiently by streamlining the preview process, making it easier to customize websites for mobile devices.”

Basically, it allows you to sync all URL changes to every shadowed device and inspect HTML and CSS on each and every one of them.

Here are some features Adobe® Shadow provides:

  • Synchronized Browsing and Refreshing (Device Pairing) — Wirelessly pair multiple iOS and Android devices to your computer.
  • Remote Inspection —Target a device for remote inspection and using familiar development tools, make changes to your HTML, CSS and JavaScript and see your device update instantly.
  • URL Monitoring — Shadow monitors the Address Bar in Chrome, and sends updates to Shadow devices as they happen.

Setting the system up isn’t hard at all; there are, however, 3 things you must download to get things up and running:

  1. You need to download the Adobe® Shadow service which installs onto your desktop. It acts as a server then communicates with all your devices.
  2. Download and install the Chrome browser extension which you would use to control your Shadow devices.
  3. Finally, each device (Android or iOS) must install their respective Shadow app.

Combining all 3 pieces of the puzzle, hook them up, and there you go!

Adobe® Shadow is excellent for traditional websites, where every page is uniquely named (i.e. each page has a unique URL), because Shadow devices follow URL paths sent by the host and interact with the native browser. Most AJAX elements on the page, however, will not be compatible with Shadow for that reason. Web applications built purely using JavaScript, Sproutcore per se, will not work.

Then, what would Adobe® Shadow be used for? Drupal! Shadow is excellent for Drupal front-end development! It really speeds things up for designers and themers. The built-in HTML CSS inspector will let you see what’s going on with each device and you can take screenshots for all of them at once!

For further information, please visit Adobe Shadow.

Jul 16 2012
Jul 16

Sometimes we all need reminders on the seemingly simple things. This is one of those snippets of code that I find myself needing from time to time. I decided to put it here so I can easily find it in the future. Hopefully it can help you too. I borrowed most of the code/concepts from the comments at http://api.drupal.org/api/drupal/developer!theme.php/function/theme_block/6.

The below PHP code provides examples of how to easily display a Drupal 6 block using code. This may be something you put in a Drupal 6 template file or a Drupal 6 theme function.

If you just want to get the content of the Drupal 6 block, you can use the following code:

$block = module_invoke('MYMODULE', 'block', 'view', 0);
print $block['content']

If you want to print the themed version of the Drupal 6 block, you can use the following code:

// The name of the module implementing hook_block.
$module = 'MYMODULE';
 
// The delta of the block, may be a number such as 0 or 1, or may be a string 
// such as 'mymodule_block' depending on how hook_block was implemented.
$delta = 0;
 
// Get the block as an object and set the module and delta properties.
$block = (object) module_invoke($module, 'block', 'view', $delta);
$block->module = $module;
$block->delta = $delta;
 
// Now you can print the themed block.
print theme('block', $block);

Simple, but useful.

Jul 16 2012
Jul 16

There are many forum links with numerous hacks detailing how to create a single exposed filter that combines search across multiple fields.   In Views 3 and Drupal 6 or 7 it is as simple as installing the Views Filter Populate
Setting up groups for views populate filter

Setting up groups for views populate filter

And that’s about it – just configure the new global filter to include your desired fields

Configure views filters populate

Configure views filters populate - include the fields you want searched

There isn’t much to know about this module, although I certainly haven’t tested it against dates or numbers, and I rather doubt that works. For text it works like a charm though – http://www.youtube.com/watch?v=AwZj8o2v4uM for the folks who like videos here’s your 1:45 of fun

One filter, two fields... yum

One filter, two fields... yum


Thanks + add any questions or comments below
Jul 11 2012
Jul 11
Modules of the month story banner illustration.

In June 2012, there were over 160 new Drupal modules released. This article provides some coverage for the most noteworthy of those modules, at least from our point of view. As in the past editions of this article, we generally ignore modules which are only for limited use cases or which simply provide integration of commercial third-party services. We also have not tried out many of these modules and have not thoroughly tested any of them. We normally don’t list modules that seem to be far from “ready” (e.g. no actual release yet), but we can make no claims as to the stability of the modules covered. Be sure to back up your database before testing new modules that might cause pain and suffering.

I think that many might agree that some of the most significant new modules from June were Author, Edit, and Layout—released by Angie Byron and Wim Leers as part of the Acquia-sponsored Spark distribution, which aims to improve the content-authoring user experience for Drupal 8 (the current distribution and modules allows us to use these improvements in Drupal 7 and help improve them). This work is still not ready for use on production sites (“dev” releases at most), but the progress is exciting, nonetheless. And despite the fact that Acquia is sponsoring development, we can all contribute to this awesome project by experimenting and reporting our experience (bug reports or ideas about ways to further improve the user experience) and/or submitting patches. We are definitely excited about Spark!

Thanks to Sascha Grossenbacher and Miro Dietiker of MD Systems there are a number of new support plugins for the Translation Management Tools (TMGMT) which they have recently released, now providing support for translation services available from Google, Microsoft, MyGengo, Nativy, and Supertext. Each of these new modules that extend the main Translation management module are currently available as dev releases for Drupal 7.

Matt Cheney of Pantheon Systems has also recently released a number of exciting “apps” (modules which depend on the Apps module) to flesh out the feature-set of their popular Panopoly distribution; these include: Panopoly Admin , Panopoly Core , Panopoly Demo , Panopoly Images , Panopoly Magic , Panopoly Pages , Panopoly Search , Panopoly Theme , Panopoly Users , Panopoly Widgets , and Panopoly WYSIWYG. All of these new modules are still considered to be in “beta” for Drupal 7, and while some of these may work without the Panopoly distribution, I won’t cover their functionality in detail. They do appear to provide some useful enhancements to Drupal’s standard installation and what their distribution could formerly offer, so this is some significant progress and worth taking a look at if you want to provide a friendly user experience or want to keep up with the latest and greatest in development for distributions.

The rest of the most noteworthy modules are listed in alphabetical order with brief descriptions of their functionality, development status, and module categories on Drupal.org (in some cases, we selected appropriate categories if none were provided on the project page. A couple are not actual modules, but are included as Drupal “projects” also worthy of mention.)

*/ Bean Panels

The module, authored by Lee Rowlands of PreviousNext, allows Beans to be used within Panels. Very cool!

Status: There is a stable release available for Drupal 7.

Booking.com API

The module, written by Rafal W., is an API for Drupal developers to allow us to build Booking.com (hotel booking) features into our sites.

Status: There is a dev release available for Drupal 7.

Clean Comments

The module, written by Manuel Garcia, adds a bit of JavaScript to each page which hides the comment links (edit/delete/reply) so that they only appear when hovering over a comment.

Status: There is a dev release available for Drupal 7.

Community Media Header

The module, written by Kevin Reynen of makedatamakesense.com, allows you to provide header images which can vary based on site section or context.

Status: There is a dev release available for Drupal 7.

Conditional Rules

The module, from Jason Zhang of the Australian National University, allows you to provide branched conditions for Rules using “if / else” and “switch / case” so that you don’t need to create multiple similar rules just to manage basic differences in conditions. This functionality is a long time coming, in my opinion, so I’ll definitely be giving this one a whirl.

Status: There is a dev release available for Drupal 7.

Contentment

The module, written by Peter Anderson of Alma Technology, gets its name as a contraction of “content management”, which might seem odd since one might say that Drupal, itself, is for for content management. So what does it do? It provides a nicer overview of site content with tabs for each content type, links and overview of numbers of comments, etc. From what I’ve seen, these are sweet improvements for site administrators. It would be nice to see such enhancements to the content overview pages in Drupal 8.

Status: There is a release candidate available for Drupal 7.

Cryptolog

The module, from Mark Burdett of the Electronic Frontier Foundation, enhances user privacy by replacing IP addresses in site logs with randomized identifiers. Each identifier is unique to an IP address for each day, so you can still analyze site statistics (such as visitors per day). This would be useful for certain kinds of sites where user privacy might be more important, but it might also make it harder to track longer term patterns of spam posting or repeat visitors.

Status: There is a dev release available for Drupal 7.

Dropdown Checkboxes

The module, by arijit dutta of Faichi Solutions, integrates the DDCL library, to replace normal HTML select lists with a drop-down checkbox list for better usability. It would be nice to see this kind of functionality natively provided by browsers.

Status: There is a release candidate available for Drupal 7.

DrupalPro

The project, contributed by Mike Stewart of Media Done Right, is not a module at all, but definitely an interesting project for people who want to get up and running with a new Drupal development environment. It’s an Ubuntu-based VirtualBox disk image which can be run right off of a USB3 stick. It has loads of great utilities already installed, as well, of course, as a full DAMP stack. Assuming your production server is Linux-based, this Virtual box should provide a much more compatible testing environment than a MAMP/WAMP development environment. The disk image includes Drush 5, Git, Netbeans, Compass, Sass, Dreditor, and a number of other very useful utilities that can take time to set up.

Status: There is a beta release available for Drupal 7.

Drush live

Categories: Drush

The module, produced by James Silver of ComputerMinds, provides some nice enhancements for Drush. Explaining it here is outside the scope of this article, but it does look like it could be useful.

Status: There is a stable release available for Drupal 7.

Entity Property Field

The module, by Erik Summerfield of Phase2 Technology, provides a simple display field with format widgets to display entity properties as if they were normal fields (e.g. to provide a field with formatters to show the date/time updated information for a node or other entity.)

Status: There is a beta release available for Drupal 7.

Felix

The module, by Maurits Lawende of Dutch Open Projects, provides a simplified way for site editors to add a preset selection of blocks to pre-defined page regions without any need to use block administration. Cool stuff!

Status: There is a beta release available for Drupal 7.

GMap3 Tools

The module, contributed by Ivica Puljic of MontenaSoft, is a developer API for integrating Google Maps (version 3) into a Drupal site.

Status: There is a dev release available for Drupal 7.

Handy Block

The module, developed by Jeremy Epstein, helps eliminate the need for custom modules just to provide a block which relates to the current entity. It’s considered a “convenience module” for developers and themers.

Status: There is a stable release available for Drupal 7.

Image Annotator

Categories: Fields

The module, written by Peter Droogmans, helps add annotation markers to images.

Status: There is a dev release available for Drupal 7.

Image Autosize filter

The module, written by Hai-Nam Nguyen of Open Web Solutions, keeps content consistent and streamlines the editorial workflow by forcing a preset image size based on the selected image “alignment” (left/right/center/none).

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Image Preset

The module, by Yuriy Babenko of Suite101, allows you to simply select an ImageCache preset for Views, DisplaySuite or other places where you might set up an image to be displayed.

Status: There is a stable release available for Drupal 7.

jQuery File Upload and jQuery Kaltura Uploader

The and modules, both coded by John Youssef of JesoX, are similar modules which provide enhanced file upload functionality and a “multi-uploader”. Both modules depend on the jQuery Update module and look similar. Differences include that the jQuery File Upload module supports non-image/video documents (e.g. .doc and .pdf files, etc), whereas the Kaltura uploader supports only images and video file-types, requires the Kaltura module, and uploads files to your configured Kaltura account.

Status: There are dev releases available (for both modules) for Drupal 7.

jQuery LocalScroll

The module, written by Gabor Szanto, uses the jQuery LocalScroll library (installed separately using the Libraries API module) and allows you to build sites with links to anchor points on a page which smoothly scroll to those anchor point links, when clicked. This can look pretty cool and is ideal for mini-sites or to minimize page requests. See the project page for links to example sites.

Status: There is a dev release available for Drupal 7.

JSON 2

The module, is also produced by Peter Droogmans and provides integration of the JSON 2 JavaScript library. This could definitely be useful.

Status: There is a stable release available for Drupal 7.

Link API

Categories: Content

The module, by Chris Skene of PreviousNext, provides some nice tools for developers to manage links on a Drupal site. This can include validation of links, maintaining a list of all links, etc. This definitely looks handy!

Status: There is a beta release available for Drupal 6 (and we are hoping this will get ported to D7.).

Link Badges and Menu Badges

The and modules, both developed by Wayne Eaker of Zengenuity, work together (Link badges is a developer API which is used by Menu badges and can be used by developers for other modules) to provide iOS-style “badges” next to links, e.g. to indicate the number of unread messages, items in a cart, etc. Very nice!

Status: There are stable releases available for Drupal 7.

Microsites

The module, also contributed by Chris Skene of PreviousNext, helps simplify using Drupal to produce “Microsites” within a Drupal installation, so they can have their own menus, etc. This looks very cool!

Status: There is a beta release available for Drupal 6.

Ming

is yet another module by Chris Skene of PreviousNext. Ming allows site developers to work with data stored in MongoDB databases and provides a number of nice features, including maintaining multiple persistent connections to MongoDB databases, shortcuts for MongoDB tasks and for accessing stored objects without need for creating full MongoID classes, etc. This looks very interesting.

Status: There is an alpha release available for Drupal 7.

Postal Code Validation

The module, produced by Liam Morland of University of Waterloo, is a developer API which helps provide postal code validation for a number of different countries. It has no user interface of its own, but allows developers to utilize its functions in their own modules.

Status: There is a release candidate available for Drupal 7.

Promo node

The module, created by Mikke Schirén of NodeOne, provides a system for promoting various Drupal nodes on your site, thus eliminating the need for creating a special “promo” content type.

Status: There is a dev release available for Drupal 7.

Publish button

The module, also created by Mikke Schirén, provides a simple “publish” button next to the “Save” button so you don’t need to force your site’s content creators to check the “publish” box, then click on “Save”. This provides a more natural workflow and helps prevent accidentally creating nodes without publishing them (or vice-versa, depending on how you might create your content type defaults.) Very simple… but very nifty!

Status: There is a beta release available for Drupal 7.

Reverse Proxy Check

The module, written by Justin Emond, helps verify that nothing has broken your reverse proxy caching for anonymous site visitors (e.g. Varnish). It provides an extra line in your site’s status report (admin/reports/status)

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Rules URL Argument

The module, written by Tadej Baša, allows you to check for and get the value of arguments used in the URL and use them in Rules.

Status: There is a stable release available for Drupal 7.

SAML Service Provider

The module, by Marcus Deglos of Acquia, is pretty cool… it allows users to verify their identity with a SAML IDP (Identitity Provider) server to streamline registration and login.

Status: There is a dev release available for Drupal 7.

Scheduler Workbench Integration

The module, produced by William Hurley of Forum One Communications, allows you to set dates for Workbench-moderated content to be published and/or unpublished. This is definitely useful for managing the scheduled release of editor-moderated content.

Status: There is an alpha release available for Drupal 7.

Search synonyms

Categories: Search

The module, produced by Aidan Lister, allows you to add synonyms for search terms to the index so that, for example, people searching for “Holland” will see full search results which also include the (usually-synonymous term), “The Netherlands”.

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Taxonomy add previous

The module, created by Joachim Noreiko, helps streamline the process of adding related or similar taxonomy terms by automatically populating the new term fields with the values used for the previous taxonomy term and provides a second link for this functionality next to the normal “add term” link. This could definitely be useful for certain use cases.

Status: There is an alpha release available for Drupal 7.

Views Dataviz

The module, developed by Jurriaan Roelofs, is a modern, HTML5-based data visualization system for providing charts from Views data, etc. Nicely done!

Status: There is an alpha release available for Drupal 7.

Views Rules

The module, is another contribution (like the Conditional Rules, above) by Jason Zhang of the Australian National University, which provides integration between Rules and Views. Getting into the particulars of using this module would be a separate article on its own, but it definitely looks cool!

Status: There is an alpha release available for Drupal 7.

Views Slideshow Liquid Carousel

The module, written by Jonathan DeLaigle of Advomatic, integrates the Liquid Carousel Javascript library into Views Slideshow, allowing you to provide fluid layout to a Views Slideshow, e.g. fluidly alter the number of thumbnail links visible as the window’s width changes. This looks slick!

Status: There is a beta release available for Drupal 7.

Jul 05 2012
Jul 05
New Spammer Registered

Rules is an especially useful Drupal module for all kinds of tasks. One use you might want to put it to is providing admin notifications of certain events on your site, e.g. user registrations and the creation of new comments and content by these “untrusted” users (assuming your use case allows them to create any content at all). I recently created such rules to help monitor the creation of users, content, and comments on drupal.cocomore.com/.de. Since we use the Project module (and supporting code) to host and track issues on some Drupal modules, we allow users to create accounts and “Issue” nodes. But there hasn’t been much recent change to the modules we host, so most of the “users” turn out to be spamming scumbags who post “issues” with links to questionable sites (you know the type). Since we allow anonymous users to comment on our blog posts, we also get our fair share of comment spam, but a tricky Captcha (we’re using Riddler, these days, to filter out visitors who don’t know or can’t take the time to search the answers to simple Drupal trivia questions) helps keep comment spam to a minimum. Keeping vigilant about stomping out spam is important since leaving spam published looks unprofessional and is bad for SEO… and since it also attracts more spam (spammers see that your site leaves spammy links in place); but of course it’s also important to keep an eye on the valid posts, too, and to respond to them in a timely fashion.

So we will assume that you have a site without a massive flow of new user registrations or new content and that you want to be alerted with some useful information whenever these events occur so that you can take appropriate action (block users and clean out the spam… or respond to valid content/comments). This article will lead you, step-by-step, through the creation of three different rules on both Drupal 6 and Drupal 7 -based sites, identifying particular set-up differences between these versions of Drupal/Rules. The three events we want to create Rules for are:

  1. New user registered
  2. New comment posted (by non-staff user or “untrusted” user)
  3. New content posted (again, by some kind of “untrusted” user)
In each case, we simply want to send an HTML email* to notify at least one member of staff (anyone with the admin role and, in the case of comments on blog posts, we want to also email the article’s author.) This article does not get into the various particulars of configuring your server to be able to send mail; there are a number of factors which might differ from server to server and it’s not really within the scope of a Drupal-related article.
*Note: This article also does not cover setting up HTML mail, but some modules, such as Mime Mail help make this a relatively pain-free process and provide a “send HTML mail” action for Rules. Adding specialized modules is probably not justifiable if you don’t plan to use HTML mail for anything more than admin notifications, but if you want to email users, such modules can help you create much more attractive and useful emails.

In every case, creating a new rule starts by going to the “add rule” page:
D6: admin/rules/trigger/add
D7: admin/config/workflow/rules/reaction/add

Notify admin when a new user registers

This is a simple rule which sends an HTML email with a link to a new user’s profile, along with their username. If you allow users to register themselves on your site, you will likely notice patterns that persistent spammers follow and be alert enough to just block the most suspicious user accounts before they even start spamming your site. I won’t specify the suspicious patterns I’ve been reacting to here (I don’t want to teach spammers how to be sneakier or more effective), but if you have a spam problem, you probably already know the patterns or will quickly recognize them.

*/

Adding a new rule to react to user registrations

The first step is virtually the same on both Drupal 6 and Drupal 7. Pick a name for the rule that you will not be confused by later, add tags (categories) if you have lots of rules, or plan to make lots, and select the event, “After saving a new user account” (“User account has been created” on Drupal 6).

Drupal 6 - Rules Event is a “new user account”Drupal 7 - Rules Event is a “new user account”

Click “Add action”

The “Add action” pre-step is also almost identical in Drupal 6 and Drupal 7 and we will skip over illustrating this in the following rules:

Drupal 6 - Rules “Add Action” buttonDrupal 7 - Rules “Add Action” button

Add action “Send mail” or “Send HTML mail”

In Drupal 6, the options for sending an HTML mail (provided you have Mime Mail installed) are separate from the rest of the “Send mail…” options. In Drupal 7 they all appear together in the “System” options. Either way, you can choose to send an email to an appropriate person or group of people. The “arbitrary email address” options can be useful if you want to send email to more than one person, regardless of their site roles. You could, for example, send a mail to the author of content that received a comment (using a “replacement pattern”, i.e. “token”) and/or to a particular person. More than one email address (or token substitute) can be added to recipient fields as long as the addresses are comma-separated.

drupal6-rules-send_html_mail.pngDrupal 7 option - Send HTML mail with Rules

Complete the email subject and body

The email “subject” and “body” fields can accept a variety of tokens or “replacement patterns”. In Drupal 7, these are apparently separate from “Tokens” provided by the Drupal contrib module, Token, which of course you also have installed; the Rules replacement patterns are available even if Token is missing or disabled, but in Drupal 6, you need the Token module enabled in order to have “replacement patterns” available for use.

Drupal 6 - Configure Rules message for new user registrations drupal7-configure-message-new-user-4.png

Download import code for this rule

Rules allows you to export and import rules from saved code, so I have attached an export of this rule. Even if you don’t want exactly the same action, this could be useful as a starting point for a new rule on your site. There are four versions of the import code attached, two each for Drupal 6 and Drupal 7 (for each version of Drupal, there is one version of the rule which uses HTML mail for the admin notification email, and one which just sends a plain mail.)

Troubleshooting

I suggest initially triggering a very simple rule to send a very simple email (to test that you get your message) and then build up the complexity a small step at a time, testing as you go.

AttachmentSize 1 KB 666 bytes 1.99 KB 2.76 KB
Jun 21 2012
Jun 21

Increasingly our web pages are being bookmarked on iOS devices.  This is a good thing, however we had traditionally been using long titles on our pages and these were clumsy for end users when trying to store bookmarks.  Like 90,000 other websites we have chosen Page Title to solve this issue.  It works well with Tokens and Views and is probably one of those modules you should just install.

Here’s your 1:30 video http://www.youtube.com/watch?v=DMvXVJ2mbGQ

and a couple of screen shots for the really curious types.  It’s a simple module to install and use. Made by several of Drupal giants robertDouglass, JohnAlbin, and nicholasThompson.

Turn on page titles in the content type area

Turn on page titles in the content type area

Enjoy refreshing page titles independent of your content title

Enjoy refreshing page titles independent of your content title

Jun 19 2012
Jun 19

It’s been a busy past several days in Barcelona (for the Drupal Developer Days) and most of us who’d been sprinting during the week before seemed to be in the same condition by Sunday—rapidly running out of energy from progressive sleep deprivation from an increasingly later return to our hotels. But it’s been an exciting week for Drupal core (and contrib) development and significant work has been completed on the Drupal core (mostly building up Drupal 8, but also some for added features in Drupal 7) while a lot of important decisions have been made which will likely shape development in a number of initiatives for the coming months until the sprints at DrupalCon Munich.

In addition to the Sprint I was primarily involved in (I was just trying to get my feet wet with assisting the Drupal 8 core development process by joining the multilingual sprint, but I did write my first committed core patch—admittedly this was a very basic patch), there were also sprints running for “Views in core”, Entity API, Media initiative, Mapping in Drupal 7, configuration management, abstracting social networking, search-related sprints, the Drupal.org upgrade… and possibly more still. I’ll cover some of the highlights of the week that I’m most knowledgeable about.

Multilingual Initiative

The multilingual initiative sprinted all week before the Developer Days sessions, and even continued through the weekend. And a lot of key decisions were made and important code changes committed and pushed to the central Drupal 8.x repository.

New user interface translation improvements in Drupal 8

This is something I got to do a bit with, but Swiss developer, Michael Schmid (Schnitzel on d.o), of Amazee Labs, was the primary developer working on this task during the Sprint. He and his colleague, Vasi Chindris, were among the stars of the week. It was a real privilege to get to look over their shoulders and to get Michael’s support when it came to using Git to manage code in the sandbox we were using for the issue. (Thank you, once again, Michael!) Once everyone was happy with the work, it got committed to core. This new sandbox workflow, used for larger issues, helps avoid a lot of bugs creeping into the main branch, as has happened during previous periods of intense core development. Of course the tests and test bots catch a lot of issues which could otherwise be major headaches for all concerned (automated testing was also a part of Drupal 7 development). If you recall, the long wait for Drupal 7’s release was due to hundreds of critical bugs. Now this should be a thing of the past since we have an established threshold for critical issues; and the core team only commit new patches to the central repository when we are below that threshold (15 “critical” bugs, 100 “major” bugs… among other thresholds specified).

New system for translating Drupal’s user interface

The new user interface translation system allows you to keep imported (community contributed) translations separate from customized translations and search for a particular translation within either or both categories as well as filter by translated strings, untranslated strings, or both. If you have any unsaved translations, they are highlighted to help remind you not to leave the page without saving them and there discussion about providing a dialogue to prevent a site admin from accidentally leaving the page with unsaved changes, too. There is also an issue to allow the string search to be non-case-sensitive (checkbox) to find more strings that contain a particular word or phrase, regardless of text case. Since this feature came up in discussion after the rest of the user-interface changes had already been made, we elected to put the discussion about adding this feature in a separate issue. If you have ideas for what might further improve the Drupal 8 user-interface translation workflow, your input is valued.Customized and imported (community) translations are stored separately

*/

New content language options

Drupal 8 has new language settings per content typeYou can enable translation for a particular content type and also choose to hide the language selector (automatically selecting the language for a new piece of content by any of a number of contextual rules). The automatically selected language for a new piece of content can be any particular language enabled on your site, “not specified”, “not applicable”, “multiple”, the “site’s default language”, the “current interface language”, or the “author’s preferred language”. While all these settings might arguably be a bit confusing for new users, they should help smooth the content creation and translation workflow for most sites. Of course the option to “enable translation” is hidden if the default language for the content type cannot be resolved to a single language (i.e. for “not specified”, “not applicable”, or “multiple”), since translation does not make sense here.

Translate the English UI to… English!

Drupal 8 — Enable English UI translationIn the edit preferences for the English language, you can enable translation to English and then it’s easy to change, for instance, the “Log out” link to “Sign out” (or “Disembark”, “Abandon ship”, “Terminate session” or anything else you might want on a particular site). Of course this could also be useful for fixing any oddities you find in the UI strings provided by contributed modules if you find a mistake in a field description, for instance, you don’t need to wait for a module developer to commit your patch or add a “site English” custom language just to modify a few strings.

Configuration Management related to Multilingual sites

Drupal core team leads and other sprinters discussed multilanguage configuration

One of the biggest issues of the week was determining how multilingual configuration would be handled in Drupal 8. The core team knew that they wanted to store language configuration in files rather than in the database, so that it’s easy to “push” new language configurations to an established site that already has content, among other benefits of this approach. But this brought with it a number of challenges which the Multilingual Initiative team, Configuration Management Initiative team, and other interested parties discussed in several sprint discussions through the week. Many of the standard configurations for a site might also differ, depending on the language: you might, for example, want a different site name or site slogan or logo for each language. There were three different proposals for how to handle multilingual configuration, and to keep a long story short, the final decision was to go with “Plan B” (or a minor variant, thereof). You can still lend your voice to the “review” process in the main issue for the language configuration system in Drupal 8. If you would like an overview of the plans, there is a nice graphic by Gábor Hojtsy (the Multilingual Team lead) which outlines the differences between the three proposals and some variants.

Drupal 8 Configuration Management

Greg Dunlap (“heyrocker” on drupal.org) presented the new configuration management

Angie Byron, aka “webchick” gave a quick overview of the configuration management initiatives goals, tooOne great session from the weekend was the Introduction to the Drupal 8 Configuration Managment System by Greg Dunlap (“heyrocker” on Drupal.org), the Configuration Management Initiative team lead. There has been some good progress in determining what this is going to look like, some of which took place during the sprints in Barcelona. Basically, this will be a bunch of smaller files stored within a logical directory structure in the sites/[…]/files directory. The new configuration system is currently planned to be YAML-based (rather than PHP or XML, which were used in earlier visualizations of the system). And the goal, as described by a slide in Angie Byron’s Sunday-morning keynote, “Drupal 8: What you need to know” is to be like “Features in core, only better”. The aim is to help us remove the complications involved in pushing configuration changes, modified in a development or staging environment, to a site that already has user-created content that we don’t want to lose. The main problem with the current system is that there is no consistent system: configuration settings are scattered across multiple tables, variables, files, and other locations and there is no consistent structure in any case. The idea is now to have a contexts, which Drupal responds to, when determining which configurations files to use.

Angela Byron (“webchick”) talks about the problems the new configuration management system aims to solve

What it should look like when loading a configuration from module code, is something like this:

  $config = config('image.style.large.yml';
  $config->get('effects.image_scale_480_480_1.data');

And when setting and saving configuration data:

  $config = config('system.performance');
  $config->set('cache', $form_state['values']['cache']);
  $config->save();

The YAML code for the image example, which saves configuration for the “large” image style would look something like this:

  name: large
  effects:
    image_scale_480_480_1:
      name: image_scale
      data:
          width: '480'
          height: '480'
          upscale: '1'
      weight: '0'
      ieid: image_scale_480_480_1

This should be pretty easy for developers and site builders to learn to work with and of course an interface is planned which should automatically build the configuration files, when edited by site builders. Configurations will be loaded into the “active store”. Changes are saved back to the active store and back to the YAML files so they can easily be moved between sites (staging and production sites, or completely different sites if they should have some settings in common). Building up an ideal import/export system for configurations is one of the major remaining hurdles. Update: heyrocker’s presentation slides are now available for download, so you can see other examples of Drupal 8 configuration.

Other Drupal 8 news

Twig library committed to core!

Drupal 8 now has Twig in the core/vendor directoryOne of the new developments which has received some press is that Twig, the templating system designed by Fabien Potencier, the innovator behind Symfony, which also bundles Twig, has now been added to the Drupal core repository.

However, the fact that the Twig library is in the repository does not mean that it’s ready for any kind of use yet, except for those who are working to build a new templating engine for Drupal, which uses it. How this works is still open to discussion; according to webchick, it may be that we keep both PHP-based and Twig-based templating engines to ease the pain of this change. On the other hand, while there is a learning curve involved, there are many advantages to Twig, especially in terms of security (removing PHP vulnerabilities from themes, altogether), and the saying that “the drop is always moving” applies here. It may be that Twig is the only templating engine which will be supported by Drupal 8, but if you feel strongly about this or have ideas for how to do this “right”, it’s a good time to get involved.Twig vs PHP template syntax

Context-based layout and blocks

Angela Byron lays out the plan for Drupal 8 layout with contexts

Everything in Drupal 8 will be a block or a layout area and blocks can have multiple contexts which determine their behavior (and whether or not they are displayed). This is going to be a major change which should produce much more flexible layouts and site designs. Of course this will touch on every major Drupal initiative: configuration, HTML5, mobile, multilingual… all are involved.

Drupal 8 will have clean, semantic HTML5 (and will abandon IE)!

Say goodbye to the messy nested div hell! Drupal 8 code is going to be much smaller and cleaner which will make designer/themer types love Drupal and make it possible to produce code that renders nicely, regardless of display size. Oh, and don’t worry about trying to support older versions of Internet Explorer; the community has decided it’s time to put that tiresome task to rest. Yay!

Drupal 8 development needs you!

Webchick, heyrocker, Gábor Hojtsy… all made the same point: As a community effort that’s still underway, the Drupal 8 effort needs more of the community at large to get involved and find ways to help out. There is a lot of complexity, but there will be smaller tasks that anyone could work on, so there’s going to be something for everyone. Even non-coders can help by testing, filing bug reports, helping manage the issue queues, making suggestions, documenting finished features and APIs. There are several places where you can get involved:

  • The core initiatives overview page provides information about when the different teams meet in IRC and in which channels among other information which can help people who want to find ways to get involved.
  • Drupal Ladder is a project aimed at helping more people learn how to contribute to Drupal
  • [ … ] (Comment below if you have other tips for where to get involved)

Big thanks to the organizers, sprint leads, and session speakers

The Drupal Developer Days in Barcelona were a big success because of all of you pulling together to make things happen. The local organizers made us all feel welcome and provided a lovely venue and took us out on the town just about every night. The sprint leaders helped find ways for everyone to play a part in building Drupal 8 or contributing in other ways, and the sessions were awesome.

Jun 11 2012
Jun 11
Modules of the month story banner illustration.

In May 2012, 150 new Drupal modules were released; this post provides an overview of some of the most promising modules including developer APIs, theming tools, configuration assistants, useful enhancements to other modules and much more.

Going through the list of new modules, I found it difficult, this time, to select the “most useful”. Of course what seems “useful” depends largely on ones use case, so what you find indispensable, I might I find useless today, and tomorrow I might decide it’s a vital part of my new project. With one exception, the selected modules should all be reasonably “ready for use” (i.e. they at least have a release of some kind) and are mostly modules I could imagine using, myself, even if I don’t have an immediate need for many of them. Some modules which were not included in this selection include several "third-party integration” modules, especially those for “commercial” services. And in contrast to the post made for the April’s “modules-of-the-month”, I have not attempted to sort the selection of modules by category, but instead have the list sorted alphabetically, by project name—the summaries include the categories used on the modules’ Drupal.org project descriptions (and reasonable categories have been added for a few modules which currently haven’t got any categories selected on drupal.org).

As with last time, I have not been able to personally test all of the modules, so don’t blame me if you enable one that looks promising… and it hoses your database.

*/ Addressfield Tokens

The module, by Andrew Marcus of New Signature, has already got over a hundred sites using it, so clearly this was an innovation that people had been waiting for. It’s a nifty extension to the Address Field module (so obviously depends on that) which also requires the Entity Token sub-module (part of the Entity API module). A token such as [addressfield:full] can be used to insert (in this example) a full, formatted address. It integrates well with MailChimp and Webform.

Status: There is a stable release available for Drupal 7.

Apache log4php integration

The module, by Erik Webb of Acquia, like most modules from Acquia, is complex enough that it’s not easy to summarize; that said, this module provides integration with the Apache log4php™ library to simplify the process of logging errors. It’s a “better watchdog” that uses a common-purpose library to log messages to a wide variety of backend logging systems with improved control compared to Drupal’s standard message logging (Watchdog) system. You obviously need to install the log4php library (using PEAR or the Libraries module)

Status: There is a dev release available for Drupal 7.

Article Templater

Categories: Content

The module, by John Youssef (JesoX), sounds like a great idea (caveat: I’ve yet to actually experiment with this). It provides savable structure for any content type body, including snippets, etc, so if you have a particular article format it can be easily inserted into your body field. It supports CKEditor and Wysiwyg.

Status: There is a dev release available for Drupal 7.

Block Conditional Visibility by URI Query Parameters

The module, written by Solomon Gifford, extends the normal controls for where a block is displayed to allow blocks to be shown (or hidden) if a particular query string is appended to the URL, e.g. https://example.com?referrer=google. Tres cool!

Status: There is a stable release available for Drupal 7.

Colorbox Node

The module, produced by Dennis Blake, allows you to display any page (minus header and footer) within a Colorbox modal. Despite the word “node” in the module name, it supports user pages, Views pages, Webforms, and more.

Status: There is a stable release available for Drupal 7.

Commerce Fancy Attributes The example color selector for Commerce Fancy Attributes

The module, developed by Julien Dubois and Bojan Živanović of Commerce Guys, provides a Javascript-enabled way to change the boring, ugly radio button set into a prettier selector. The example use case is a color selector used on a product’s “add to cart” form with nice color swatches to click rather than labeled radio buttons. But if Javascript is disabled, it gracefully degrades to normal radio buttons. Nice!

Status: There is a beta release available for Drupal 7.

Compass: Commerce Dashboard & Analytics Compass is my effort to turn Drupal Commerce data into comprehensible information.

The module, authored by Jurriaan Roelofs, provides nice visualizations in the form of graphs and charts of your Drupal commerce data using interactive HTML5/VML Google Charts with views integration. It has a long list of dependencies, but most of these will already be in use on a complex Drupal Commerce-enabled site.

Status: There is a alpha release available for Drupal 7.

Cookie Log

The module, produced by PK Vaish of Livelink New Media, provides a simple record of all cookies set by your site so that you can better audit cookies for compliance with the new EU “cookie law”.

Status: There is a stable release available for Drupal 7.

Corresponding Entity References As this is the next evolution of Corresponding Node References, I would like to say thanks for all the work done over on Corresponding Node References. This is almost a direct upgrade from CNR to include handling of entities.

The module, by Chris Hertzog of CODEwork Designs, allows two entity types to have references to each other which are automatically automatically updated if changed in one of the entity instances.

Status: There is a dev release available for Drupal 7.

Create-editor The development has just started and the module is not yet usable, we are just testing the concept and a complete rewrite will probably occur once we know how to deal with everything. All help is welcome.

The module, written by Finish developers Roni Kantis of Soprano Brain Alliance and Riku Virta, the front-end developer of the actual Create library, is the only project listed here which does not yet have any kind of usable release. Despite not yet being usable and being in the early stages of development, the goals of this project are so impressive and worthy of continued interest, that I felt it deserved mention. Create, from the Midgard Project allows you to integrate the browsing and content editing user experience to allow editing without going into a “content administration” form. So you can easily change content directly on a page and submit changes back to the server. I’ll certainly be keeping an eye on this.

Status: There is no real release available yet (but you can download the current state of the project as a development snapshot or check out the project with Git).

Data Visualization Wizard

The module, written by Jason Hoekstra of the U.S. Department of Education, has a goal to simplify and streamline the process of creating complex data visualizations in Drupal.

[…]Views, OpenLayers, Charts and Graphs and others provided a quick way to show data online without custom programming, but became a maintenance burden in the long run, often taking 8-32 hours to create a new visualization. For this reason, we distilled the best practices from these patterns into a single module. The end goal is to lower the technical complexity required to create new visualizations and decrease the time required to do so.

Status: There is a beta release available for Drupal 6.

Entity Reference Count

The module, written by Pablo Cerda of BlueSpark Labs, is an entity-based adaptation of the Nodereference Count module, which allows you to add an automatically-calculated field to any entity which will display a value for the number of other entities which reference it.

Status: There is a dev release available for Drupal 7.

Exclusive Value

The module, by Robert Castelo of Code Positive, is a module which provides a basic checkbox field (boolean setting) which can be enabled for any one node to make it the featured node. When the checkbox is set on one node, it is unset for all others (only one node is featured with this setting). While this might not be useful on every Drupal site, I can certainly think of situations where I would definitely make use of this simple module.

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Fallback language negotiation Change the Default language without changing the default language by using a other language as fallback.

The module, coded by German Drupal developers, Florian Weber of [di] digitale informationssysteme gmbh and Dennis Brücke, has a funny description (see quote to right). I’ve not had a need for it yet, but I’m sure it’s useful for some situations.

Status: There is a dev release available for Drupal 7.

Google Viewer file formatter

The module, by Janez Urevc of Delo, integrates the Google doc viewer to display a number of different document types (.pdf, .doc, .docx, .xls, .xlsx, .ppt, etc). It requires enabling the File entity module.

Status: There is a stable release available for Drupal 7.

LimeSurvey Sync

The module, contributed by Julien Duteil , provides integration of LimeSurvey results into a Drupal site.

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Log Em Out

The module, from Minnur Yunusov of Urban Insight, prevents multiple concurrent sessions from different IPs on the same user account by automatically logging out any previous connection if a user logs in from a different IP. For membership sites this could help prevent sharing of accounts and it should also help ensure security. In permissions, you can select which roles this behavior is applied to.

Status: There is a stable release available for Drupal 7.

Lorempixel

The module, contributed by Fredric Bergström of NodeOne, brings improved “placeholder image” creation to Drupal by accessing free images on lorempixel.com, which can be “generated” at any image size needed. It integrates with Devel generate, but can also be used to add an image as a file entity.

Status: There is a dev release available for Drupal 7.

Node Field

Categories: Fields

The module, contributed by Alexander of ADCI, LLC, allows you to add unique extra fields to individual Drupal nodes without needing to add the fields to the content type. This provides a lot of flexibility and helps prevent excessive “field clutter” or the need for more content types.

Status: There is a stable release available for Drupal 7.

Node View Permissions

The module, was (like Node Field) also developed by Alexander of ADCI, LLC, provides Drupal 7 with the permissions: "View own content" and "View any content" for each content type, just as it was in Drupal 6. This could be especially useful for D6 sites which made special use of these permissions and now need to be upgraded to Drupal 7.

Status: There is a stable release available for Drupal 7.

OG Extras

The module, contributed by one of the Drupal community’s superstars, Karen Stevenson, is a set of “extras” for Organic Groups. It’s especially useful for sites which don’t use Panels since it provides Views and Blocks for Organic Groups which don’t depend on Panels.

Status: There is a stable release available for Drupal 7.

Panels Frame

The module, written by Helior Colorado of Commerce Guys, gives Panels users a simpler way to build new complex layouts by stacking existing Panels layouts. Cool!

Status: There is a alpha release available for Drupal 7.

Pathauto i18n Taxonomy

The module, by Marco Kleine-Albers, provides i18n tokens for taxonomy paths in Pathauto so users get paths in their own language. Of course this is also good for SEO.

Status: There is a beta release available for Drupal 7.

Popcorn.js

The module, written by Kevin Reynen of makedatamakesense, integrates the cool media viewer, Popcorn.js, which includes support for YouTube and Vimeo as well as other interesting HTML5 applications.

Status: There is a dev release available for Drupal 7.

Portable path

is a module, from the great Jim Berry, which helps make it easier to move a site from a development/staging domain to “production”.

After a review of existing input filters and related modules, none seemed to do this. Some remove the domain portion of the path, making the path portable in certain contexts but not across all use cases. But none finished the job by replacing the file structure path. If someone is aware of a module doing what this does, let me know.

Status: There is a dev release available for Drupal 7.

Reviews

The module, written by Scot Hubbard of Base One Ltd, simplifies adding reviews to site content. Reviews can be configured per content type. For those of us who have had to jump through hoops using the Voting API paired with node references and creation of a “review” content type, this is definitely a breath of fresh air and I am betting the Reviews modules will quickly grow in popularity!

Status: There is a stable release available for Drupal 7.

Role Delay

The module, created by World Fallz, allows a Drupal site to automatically promote a user from a basic “Authenticated user” role (which might not have many permissions at all) to a more trusted role after a period of time and then further promote their permissions (role) after another period of time.

Status: There are stable releases available for both Drupal 6 and Drupal 7.

Save Form State

Categories: Content

The module, coded by John Youssef of JesoX, provides “autosave” functionality in Drupal forms. Woohoo! You’ll need to add some additional jQuery libraries and do a bit of configuration, but this definitely does look promising.

Status: There are dev releases available for both Drupal 6 and Drupal 7.

TagCanvas tagcanvas.png

The module, written by Chin Kiong Ng of MyFineJob.com, integrates the TagCanvas library, which uses the HTML5 Canvas to build one of those fancy new 3D animated tag clouds, similar to what Cumulus does, but without using Flash (thank God!). It depends on the Tagadelic module, used by over 30,000 Drupal sites and I can only imagine that TagCanvas could quickly gain thousands of installations.

Status: There is a stable release available for Drupal 7.

Template Field Variables This is a utility module for themers. Its only purpose is to make Drupal template development less painful. It has no front-end. It stores no data. It implements no hooks.

Categories:

The module, by Jeremy Epstein, is a nifty new theming tool which takes the pain out of theming fieldable entities. Variables hidden in the massive nested arrays are moved into simple variables. It works on all core content types and fields as well as many fields and content types provided by the most popular contributed modules (link, email, date, reference, etc). This should make theming a bit less headache and a bit more fun. Yay!

Status: There is a stable release available for Drupal 7.

Tooltip Field Formatter

Categories:

The module, developed by Marc van Gend, uses BeautyTips to provide a nice display of field contents when you mouse over an appropriate icon or other trigger. Nicely done, Marc!

Status: There is a beta release available for Drupal 7.

Users Export

The module, created by Aaron Klump of In the Loft Studios, is a lean module with basic features for exporting common fields from the user table into common formats (e.g. CSV). It has an API which developers can use to extend the set of fields that it can export.

Status: There is a stable release available for Drupal 7.

Views iCal

The module, developed by Max Rakhimov, allows you to create iCal feeds of events from Views, simply and easily.

Status: There is a beta release available for Drupal 7.

Workbench Moderation Notes

Categories: Utility

The module, by Kevin Miller of Cal State Monterey Bay, provides a “Notes” field to display comments attached to changes in the moderation state of content revisions managed by Workbench Moderation; it improves communication in the editorial workflow process.

Status: There is a dev release available for Drupal 7.

Xtools

The module, by Bart Feenstra, is yet another module for to help developers test the modules they are writing. It allows developers to create “blueprints” against which input and output is checked. I look forward to see how this develops and to giving it a go.

Status: There is a dev release available for Drupal 7.

May 28 2012
May 28

In my last post, we learned how to customize CKEditor with the WYSIWYG Module. We explored how to apply our own settings to CKEditor using a little javascript and a small custom module. Today we're going to delve even deeper into what we can customize in CKEditor. Specifically we'll be looking into the dialog API. By the time we're done with it, our CKEditor will be jacked up with a faux-hawk,  flaming skull tattoos, and ready to stroll into the club and punch the first guy that looks at him cock-eyed.

Getting Started

To start, you'll need to have read my last post (http://fuseinteractive.ca/blog/wysiwyg-module-ckeditor-taming-beast) because that's where we're taking off from. You'll also need the little module we made because we're going to be adding some stuff to it. We won't be doing much php here, but a bit of javascript knowledge and OOP concepts will be helpful, especially if you want to make your own customizations beyond what we go over in this tutorial.

This tutorial should work for either Drupal 6 or 7. If you want to skip the tutorial and just browse the module code (there's lots of comments), I've attached a zipped copy of the finished module at the bottom of the post.

1. Dialog Defaults

Clients always seem to want the "Table" button in CKEditor and I sort of hate giving it to them because they always look terrible in the end. More often than not, however, it can't be avoided. Recently I had a client who didn't want borders around their tables. I told them to just change the "border" field to zero in the dialog, and they said "Can't you just change the default?". I said "No", then they said "Seriously?", then I said "I'll look into it". And I looked into it. Turns out you can and it's actually kind of easy, thanks to our ckeditor_custom module. All you need to do is open up the ckeditor_custom_config.js file in your favorite text editor and add this to the end of the file:

// When opening a dialog, a "definition" is created for it. For
// each editor instance the "dialogDefinition" event is then
// fired. We can use this event to make customizations to the
// definition of existing dialogs.
CKEDITOR.on( 'dialogDefinition', function( event ) {
 
  // Take the dialog name
  var dialogName = event.data.name;
 
  // The definition holds the structured data that is used to eventually
  // build the dialog and we can use it to customize just about anything.
  // In Drupal terms, it's sort of like CKEditor's version of a Forms API and
  // what we're doing here is a bit like a hook_form_alter.
  var dialogDefinition = event.data.definition;
 
  // Uncomment to print the dialogDefinition to the console
  // console.log(dialogDefinition);
 
  // Check if the definition is from the dialog we're
  // interested in (the "table" dialog).
  if ( dialogName == 'table' ) {
 
    // .getContents() returns an object reference to a set of fields in the
    // dialog, also referred to as tabs. The Table dialog has two tabs:
    // "Table Properties" and "Advanced". Each of those has an id. In this case,
    // the id we're interested in is 'info' for the Table Properties tab.
    var infoTab = dialogDefinition.getContents( 'info' );
 
    // Once we have the tab reference, we can use the object's .get() method
    // to get another object reference, this time to the field we want to change
    // Fields also have ids. The border field id is "txtBorder"
    var borderSizeField = infoTab.get("txtBorder");
 
    // Set the border to 0 (who uses html table borders anyway?)
    borderSizeField['default'] = 0;
  }
});

Then, turn on your browser's javascript console (in chrome go View > Developer > Javascript Console), reload the page, and click the table button. An object will be spat out into your console. You can expand it to see the various properties and methods that belong to the dialog definition. Here's what mine looks like:

I expanded the "contents" propery because I know that's where they store the tabs and fields. Oh look, it's the id we're looking for: "advanced". I guess I could have guessed that, but now I know for sure. I can do the same thing to figure out which field to customize:

var advancedTab = dialogDefinition.getContents( 'advanced' );
console.log(advancedTab);

And the output again:

Cool. It's a big mess of nested objects and arrays. Spitting it out is easy, figuring out what you're looking for is a the hard part. It's sort of a mix of examining the object in the console, reading through the API documentation, and a bit of testing. For example, you may have been wondering how I knew about the .getContents() and .get() methods. Well it was a combination of the API documentation (specifically the definitionObject class and the contentObject class)  and the example code on one of the "How to" pages. Also, the dialog API example page was helpful.

Another REALLY nifty thing that you can do is use the Developer Tools plugin which was added in CKEditor 3.6.

2. Custom Dialogs

So what else can we do? Well, you could define your own dialog and assign it to a button in the toolbar. Why would you want to do this? I don't know. But it could come in handy. Just for fun, let's make a new dialog that takes a youtube Video ID, and a few parameters, and outputs the correct iframe html. (Yes, there are plenty of existing drupal modules that handle youtube embedding already, but really this is more about learning the API, not about innovation).

Open up your ckeditor_custom.js file and add this to the end: 

// Listen for the "pluginsLoaded" event, so we are sure that the
// "dialog" plugin has been loaded and we are able to do our
// customizations. We're going to do this for every instance of CKEditor
// but technically you could only do it for certain ones
for (var editorId in CKEDITOR.instances) {
 
  // Get a reference to the editor
  var editor = CKEDITOR.instances[editorId];
 
  // Add the even listener with the editor's .on() function
  editor.on('pluginsLoaded', function(ev) {
 
    // If our custom dialog has not been registered, do that now.
    if (!CKEDITOR.dialog.exists('youtubeDialog')) {
 
      // Register the dialog. The actual dialog definition is below
      CKEDITOR.dialog.add('youtubeDialog', ytDialogDefinition);
    }
 
    // Now that CKEditor knows about our dialog, we can create a
    // command that will open it
    editor.addCommand('youtubeDialogCmd', new CKEDITOR.dialogCommand( 'youtubeDialog' ));
 
    // Finally we can assign the command to a new button that we'll call youtube
    // Don't forget, the button needs to be assigned to the toolbar
    editor.ui.addButton( 'YouTube',
      {
        label : 'You Tube',
        command : 'youtubeDialogCmd'
      }
    );
  });
}
 
/*
  Our dialog definition. Here, we define which fields we want, we add buttons
  to the dialog, and supply a "submit" handler to process the user input
  and output our youtube iframe to the editor text area.
*/
var ytDialogDefinition = function (editor) {
 
  var dialogDefinition =
  {
    title : 'YouTube Embed',
    minWidth : 390,
    minHeight : 130,
    contents : [
      {
        // To make things simple, we're just going to have one tab
        id : 'tab1',
        label : 'Settings',
        title : 'Settings',
        expand : true,
        padding : 0,
        elements :
        [
          {
            // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definition.vbox.html
            type: 'vbox',
            widths : [ null, null ],
            styles : [ 'vertical-align:top' ],
            padding: '5px',
            children: [
              {
                // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definition.html.html
                type : 'html',
                padding: '5px',
                html : 'You can find the youtube video id in the url of the video. 
 e.g. http://www.youtube.com/watch?v=<strong>VIDEO_ID</strong>.'
              },
              {
                // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definition.textInput.html
                type : 'text',
                id : 'txtVideoId',
                label: 'YouTube Video ID',
                style: 'margin-top:5px;',
                'default': '',
                validate: function() {
                  // Just a little light validation
                  // 'this' is now a CKEDITOR.ui.dialog.textInput object which
                  // is an extension of a CKEDITOR.ui.dialog.uiElement object
                  var value = this.getValue();
                  value = value.replace(/http:.*youtube.*?v=/, '');
                  this.setValue(value);
                },
                // The commit function gets called for each form element
                // when the dialog's commitContent Function is called.
                // For our dialog, commitContent is called when the user
                // Clicks the "OK" button which is defined a little further down
                commit: commitValue
              },
            ]
          },
          {
            // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definition.hbox.html
            type: 'hbox',
            widths : [ null, null ],
            styles : [ 'vertical-align:top' ],
            padding: '5px',
            children: [
              {
                type : 'text',
                id : 'txtWidth',
                label: 'Width',
                // We need to quote the default property since it is a reserved word
                // in javascript
                'default': 500,
                validate : function() {
                  var pass = true,
                    value = this.getValue();
                  pass = pass &amp;&amp; CKEDITOR.dialog.validate.integer()( value )
                    &amp;&amp; value &gt; 0;
                  if ( !pass )
                  {
                    alert( "Invalid Width" );
                    this.select();
                  }
                  return pass;
                },
                commit: commitValue
              },
              {
                type : 'text',
                id : 'txtHeight',
                label: 'Height',
                'default': 300,
                validate : function() {
                  var pass = true,
                    value = this.getValue();
                  pass = pass &amp;&amp; CKEDITOR.dialog.validate.integer()( value )
                    &amp;&amp; value &gt; 0;
                  if ( !pass )
                  {
                    alert( "Invalid Height" );
                    this.select();
                  }
                  return pass;
                },
                commit: commitValue
              },
              {
                // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dialog.definition.checkbox.html
                type : 'checkbox',
                id : 'chkAutoplay',
                label: 'Autoplay',
                commit: commitValue
              }
            ]
          }
        ]
      }
    ],
 
    // Add the standard OK and Cancel Buttons
    buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ],
 
    // A "submit" handler for when the OK button is clicked.
    onOk : function() {
 
      // A container for our field data
      var data = {};
 
      // Commit the field data to our data object
      // This function calls the commit function of each field element
      // Each field has a commit function (that we define below) that will
      // dump it's value into the data object
      this.commitContent( data );
 
      if (data.info) {
        var info = data.info;
        // Set the autoplay flag
        var autoplay = info.chkAutoplay ? 'autoplay=1': 'autoplay=0';
        // Concatenate our youtube embed url for the iframe
        var src = 'http://youtube.com/embed/' + info.txtVideoId + '?' + autoplay;
        // Create the iframe element
        var iframe = new CKEDITOR.dom.element( 'iframe' );
        // Add the attributes to the iframe.
        iframe.setAttributes({
          'width': info.txtWidth,
          'height': info.txtHeight,
          'type': 'text/html',
          'src': src,
          'frameborder': 0
        });
        // Finally insert the element into the editor.
        editor.insertElement(iframe);
      }
 
    }
  };
 
  return dialogDefinition;
};
 
// Little helper function to commit field data to an object that is passed in:
var commitValue = function( data ) {
  var id = this.id;
  if ( !data.info )
    data.info = {};
  data.info[id] = this.getValue();
};

I'm not going to go into too much detail about the above code (I'll let the comments help guide you along), but just to recap, there's a couple of key concepts going on here. The first bit of code, we're dealing with registering the dialog with CKEditor so it knows it exists and how to find it. We're also creating the button that will be available in the toolbar, and binding it to a new command that will launch the dialog. The second part of the code we're actually defining the dialog itself. We add some form elements and buttons, a couple layout boxes, and finally a "submit" function that handles the user input and outputs to the editor text area.

Okay so that's all well and good. Clear the necessary caches and reload the page your editor is on. Wait... there's no button. That's because there's one more step we need to do. Since the available buttons are defined in the WYSIWYG profile, our button never gets passed on to the toolbar. To make things simple, we're going to manually add it in our ckeditor_custom.module file:

if (!empty($remaining_buttons)) {
  // reset the array keys and add it to the $new_grouped_toolbar
  $new_grouped_toolbar[] = array_values($remaining_buttons);
}
 
// This is our new youtube command / dialog that we created in
// ckeditor_custom_config.js. If we don't add this here, it won't
// show up in the toolbar!
$new_grouped_toolbar[] = array('YouTube');
 
// Replace the toolbar with our new, grouped toolbar.
$settings['toolbar'] = $new_grouped_toolbar;

Now, reload the page with your editor on it (you may need a cache clear) and you should see your new button in the toolbar. Unfortunately, the button is blank. That's okay though because we can style it up with a little css. First, create a css file called "ckeditor_custom.css" in the module folder with this css in it:

/* Hide the icon */
.cke_button_youtubeDialogCmd .cke_icon {
  display: none !important;
}
 
/* Show the label */
.cke_button_youtubeDialogCmd .cke_label {
  display: inline !important;
}

The we need to add the css to the page in our module file, just after where we added the YouTube button

// This is our new youtube command / dialog that we created in
// ckeditor_custom_config.js. If we don't add this here, it won't
// show up in the toolbar!
$new_grouped_toolbar[] = array('YouTube');
// Add a css file to the page that will style our youtube button
drupal_add_css(drupal_get_path('module', 'ckeditor_custom') . '/ckeditor_custom.css');

Reload the page, and you should see your button there in all it's glory. Try it out. It should look something like this:

3. Conclusion

So we've done it. We customized an existing dialog and even created our own. To be honest, however, our dialog implementation probably wasn't the most robust way of doing it. The WYSIWYG module actually comes with api functions to add your own "plugins" as buttons in the toolbar. This would really be the way to go moving forward as it would integrate the plugin into WYSIWYG and would make the button available in the WYSIWYG profile settings page. Plus it would be the more "Drupal" way of doing things. My example above was really more of a quick and dirty dialog implementation that works in a pinch. Plus, it gave us a change to quickly explore the CKEditor API and learn something new.

Perhaps in a future post, I'll describe how to take our custom dialog and integrate it as a plugin in WYSIWYG, but until then, you can always browse the WYSIWYG module code yourself and see what you can figure out. There are also some good resources listed on the WYSIWYG Project page.

Here's the finished ckeditor_custom module:

May 17 2012
May 17

Recently I had the privilege of being part of a team that converted the BMJ (British Medical Journal) to Drupal. The BMJ (British Medical Journal) is one of the world’s top five international peer reviewed medical journals with more than 1.5 million unique visitors and 6.8 million page views per month.You can read the about the project and it's success at http://drupal.org/node/1557636

May 14 2012
May 14

This is a guest post from Adam, my Co-founder at BEgINr Media

When finished: After you get through this tutorial you will have made a custom Quicktabs style in Drupal 6.

This is how to do it.

Stuff I am assuming:
...you have downloaded the Quicktabs module from Drupal.org and Install it.
...you have a photo editor (Gimp, Photoshop, etc)

  1. If you choose you can build Quicktabs from scratch. This would mean building your own CSS and files. I am to lazy for this, so for this tutorial we are going to take a lot of the code and images from an existing tab style. To get started I took a copy of the Garland tab style and pulled it down to my local machine (just copy the files and paste them somewhere you can easily get to them).
  2. Take the Garland folder and give it an unique name. This will end up being the name that you select in the tab style drop-down. Also, while you are renaming things make sure to change the garland.css file to something unique as well. Note: if you site does not need right to left display you can delete this css file.
  3. Open up your newly named css file in a code editor. Once you open this file you will notice that the css is still using the old tab style theme of Garland. To fix this simply replace “garland” with the name of your css file. So for example if you named your css file “quicktabs.css” you would substitute “garland” with “quicktabs”.
  4. Before we start to edit the images and css this is a good time to check and make sure your new tab style code is getting read. To check this simply go to the admin section for quicktabs and in the tabstyle drop down change the style to your newly created style (http://yoursite.com/admin/build/quicktabs). Note: if you see the same style has the one you copied the css and images from your code is getting read correctly. If you see nothing make sure that you have changed the css file to look for your new tab style (Garland -> Quicktabs).
  5. Open up your photo editor and grab the images that you would like to change. For this example, I am going to edit both the left and right tab images. Note: this is a horizontal Quicktabs so I have no need for the sidebar images and the sidebar code in the css. If you would prefer you can delete these from your folder. In addition to the tab left and tab right, I also am going to create two additional images to display for the non-active tabs.
  6. To get the active tabs to work, all you have to do is upload your new designs to the server. If you changed image sizes, you will have to adjust some CSS to get the images to fit properly. Getting the in-active tabs to work is also very easy. Within the code you will find the css that is getting called for the current active tab. Simply copy that and paste that before the active selectors. Once that is done all you have to do is remove the .active class and change the background images to reflect the inactive images. Remember the right image is attached to the li selector while the left image is attached to the a selector.
  7. The remaining changes for the Quicktabs are only minor. These include font-sizes, colors, margins, etc. I have provided the full code below if you are curious of the changes.

If you happen to be a more visual learner here is the CSS and images that I used to create my quicktabs style.

.quicktabs_main.quicktabs-style-spl_quicktabs {
  width: 517px;
}
 
ul.quicktabs_tabs.quicktabs-style-spl_quicktabs {
  font:bold 12px/20px Arial;
  padding: 3px 0;
  height: 20px;
  margin:0;
}
 
ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li {
  margin:0;
  padding:0;
  display: block;
  float: left;
  padding: 2px 0 1px !important;
  list-style-type: none;
  background: none;
}
  ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li:first-child {
    margin-left: 0;
  }
 
ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li a:link,
ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li a:visited {
  color: #fff;
  padding: 8px 40px 4px 40px;
  margin:0;
  font:bold 12px/20px Arial;
}
  ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li.first {
    background: url("./images/tab-q-fixed.gif") no-repeat left -23px;
    width: 168px;   margin-right: 1px;
  }
    ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li.first.active {
      background: url("./images/tab-q-fixed.gif") no-repeat left top;
    }
  ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li {
  width: 194px;
  background: url("./images/tab-info-fixed.gif") no-repeat left -23px;
  }
    ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li.active {
      background: url("./images/tab-info-fixed.gif") no-repeat left top;
    }
  ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li.last {
    background: url("./images/tab-ship-fixed.gif") no-repeat left -23px;
    width: 153px;   margin-left: 1px;
  }
    ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li.last.active {
      background: url("./images/tab-ship-fixed.gif") no-repeat left top;
    }
ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li.active a  {
  color: #585858 !important;
}
 
/* IE 6 Debug */
* html ul.quicktabs_tabs.quicktabs-style-spl_quicktabs,
* html .sidebar ul.quicktabs_tabs.quicktabs-style-spl_quicktabs {
  padding-bottom: 0px;
}
 
/* IE 7 Debug */
*+html .sidebar ul.quicktabs_tabs.quicktabs-style-spl_quicktabs li a:link {
  padding-bottom: 4px;
}
May 11 2012
May 11

So you need to theme, customize, or change the Add to cart form that is output by Ubercart? If so, read on for more information. If you are looking to change the general theme or style of the Ubercart product node page, then you might want to look at my post on theming Ubercart Product Page for Drupal 6.

I needed to heavily modify the Ubercart add to cart form for one specific product content type. This example is set up to show how to theme the Ubercart add to cart form for one specific content type (in this example it is the product content type).

Step 1: Create custom Drupal 6 module

I called my custom Drupal 6 module uc_alterations, but you can pick your own name if you are feeling creative.

First step is to create the module folder, in my case I called it uc_alterations. Then it is time to create the info file (called uc_alterations.info). Here are the contents of my info file:


core = "6.x"
dependencies[] = "uc_cart"
description = "Ubercart Add to Cart Form Alterations"
name = "Ubercart Add to Cart Form Alterations"
version = "6.x-1.0"

Step 2: Add Drupal 6 form_alter and theme functions to module

Now its time to create the module file (called uc_alterations.module). In this module file you will need to implement hook_theme, and hook_form_alter.

Here are the contents of my module file:

/**
 * Implements hook_form_alter().
 */
function uc_alterations_form_alter(&$form, &$form_state, $form_id) {
  if(stripos($form_id, 'uc_product_add_to_cart_form') === 0 && $form['#parameters'][2]->type == 'product') {
    $form['#theme']  = 'uc_alterations_add_to_cart';
  }
}
 
/**
 * Implements hook_theme().
 */
function uc_alterations_theme() {
  return array(
    'uc_alterations_add_to_cart' => array(
      'arguments' => array('form' => NULL),
      'template' => 'uc_alterations_form',
    ),
  );
}

Step 3: Add Drupal 6 template file to module

In this instance I decided to use a separate template file. If I would have preferred to use a theme function, I simply would have left out the template line in the hook_theme definition and added a function to the module file similar to the one below:

function theme_uc_alterations_add_to_cart($form) {
  //all my form theming goes here
  return drupal_render($form);
}

Since I decided to use the template approach, I created a file inside my module directory called uc_alterations_form.tpl.php. Here is an example of how that file might look:

<?php
/**
 * Template for theming the add to cart form for product products
 *
 * Available Variables:
 *   $form - contains the form array containing the product attributes
 */
//You can view the form variable by uncommenting this line
//print('<pre>'.print_r($form,1).'</pre>');
?>
<div class="product-wrapper">
  <div class="product-info-wrapper">
    <div><?php print drupal_render($form['attributes'][1]); ?></div>
    <div><?php print drupal_render($form['attributes'][5]); ?></div>
    <div><?php print drupal_render($form['attributes'][2]); ?></div>
  </div>
  <?php print drupal_render($form); ?>
</div>

You will notice that to print out the attributes you need to pull out the specific attribute ID, in this case, 1, 5, and 2. This can cause issues if you have a different development/testing environment if the attribute ID's are not exactly the same, however for some cases, this is an acceptable solution. If you need to make this work with varying attribute ID's, you will need to create some type of lookup function based on the attribute title (or another column in the table that will match up despite differing attribute ID's). Since that is a little out of the scope of this post, and this solution was acceptable in my situation, I will leave that out for now.

You will also note that at the bottom of the Drupal 6 template file, I print out the rest of the form using drupal_render. This will print out the hidden form attributes such as form id, as well as the Add to Cart button.

So there you have it, you can now theme your Drupal 6 Ubercart add to cart form.

Pages

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web