Planet Drupal

Subscribe to flux Planet Drupal - aggregated feeds in category Planet Drupal
Mis à jour : il y a 6 min 41 sec

DrupalCon Austin News: ATX Hack for Change: One Weekend, Infinite Impact

ven, 23/05/2014 - 23:32

Just before DrupalCon Austin, you can join Austin changemakers and techies for a weekend of high-energy hacking, snacking and good will at the Austin Hack for Change.

Catégories: Elsewhere

DrupalCon Amsterdam: Call for Site Building Sessions

ven, 23/05/2014 - 18:43

The Drupal 8 release is getting closer, and with it we keep hearing more and more questions about it. Share your Drupal 8 knowledge with the world at DrupalCon Amsterdam: the Site Building Track Team is calling for sessions, and we want YOU to help us out.

We are looking for proposals of sessions focused on Drupal 8. Our goal is to get everybody updated on the current status of Contrib Module 8 Status. There will even be a special two hour session which will allow Drupal 8 Module Maintainers to give a short update about the status of their modules.

If you're interested in giving a 12 minute session about your module, talk to Schnitzel or post it as a comment here.

As we all know, DrupalCon is about more than just Drupal 8, so let’s not forget Drupal 7 and 6! With Site Building we can achieve and build great sites without needing to code-- and since there are a lot of ways to reach a goal, let’s share the knowledge, and teach each other how to achieve great things. Are you using a module in really cool ways? With real life examples? Propose a session!

A special focus will also be set on layout modules. There are a lot of modules which allow us to position content on a Drupal Page. Let’s compare and analyze them, so everyone will know what each module is for and can decide for what to use them. Are you proficient with a layout module? We love to hear about it!

Submit a Session

The DrupalCon Amsterdam Site Building Track Team
Michael Schmid (Schnitzel), Amazee Labs
Ivo Van Geertruyen (mr.baileys), One Agency

Catégories: Elsewhere

Dcycle: Test your sad path first

ven, 23/05/2014 - 18:39

One of the techniques I use to make sure I write tests is to write them before I do anything else, which is known as test-driven development. If you develop your functionality before writing a test, in most cases you will never write the test to go with it, because you will be pressured to move on to new features.

I have found, though, that when writing tests, our team tends to think only about the happy path: what happens if everything goes according to plan.

Let me give an quick example: let's say you are developing a donation system for anonymous users to make donations on your site. The user story calls for a form where a donation amount can be entered before redirecting the user to the payment form. Using test-driven development and Drupal's Simpletest framework, we might start by writing something like this in our site deployment module's .test file:

// @file mysite_deploy.test class MysiteDonate extends DrupalWebTestCase { ... public function testSite() { $edit = array( 'amount' => 420, ); ... $this->drupalPost('donate', $edit, 'Donate now!'); ... $this->assertText('You are about to donate $420', 'The donation amount has been recorded'); } ... }

When you first run this test it will fail, and your job as a developer will be to make this test pass. That's test-driven development.

The problem with this approach is that it only defines the happy path: what should happen when all goes according to plan. It makes no provision for the sad path: what happens if a user puts something other than a number? What happens if 0 is entered? These are known as sad paths, and most teams never think about them until they occur (human nature, I guess).

To make sure we think about the sad path, I start by making sure the right questions are asked during our Agile sprint planning sessions. In the case of the "donation" user story mentioned above, the following business questions should be asked during sprint planning:

  • What's the minimum donation? Obviously it should not be possible to donate $0, but is $0.01 OK?
  • Is there a maximum donation? Should the system bring you to the checkout page if you enter 1 billion dollars in the donation box?

Often, the client will not have thought of that, and will answer something like: sure there should be a minimum and a maximum, and we also want site administrators to be able to edit those. Let's say team agrees on this (and the extra work it entails), the admin interface too should be tested.

Once the sprint planning session is over, I will start by writing the test based on business considerations above, and also integrating other sad paths I can think of, into my test.

Here is what our test might look like now, assuming we have a setUp() function which enables our site deployment module and dependent features (including roles); and we are using the loginAsRole() method, documented here:

// @file mysite_deploy.test class MysiteDonate extends DrupalWebTestCase { ... public function testSite() { // Manage minimum and maximum donation amounts. $this->drupalGet('admin/options'); $this->assertText('Access denied', 'Non-admin users cannot access the configuration page'); $this->loginAsRole('administrator'); $edit = array( 'minimum' => '50', 'maximum' => $this->randomName(), ); $this->drupalPost('admin/option', $edit, 'Save'); $this->assertText('Minimum and maximum donation amounts must be numeric'); $edit['maximum'] = '40'; $this->drupalPost('admin/option', $edit, 'Save'); $this->assertText('Minimum amount must be equal to or less than maximum donation amount'); $edit['maximum'] = '30'; $this->drupalPost('admin/option', $edit, 'Save'); $this->assertText('Minimum maximum donation amounts have been saved'); $this->drupalLogout(); // Make a donation, sad path $edit = array( 'amount' => '<script>alert("hello!")</script>', ); $this->drupalPost('donate', $edit, 'Donate now!'); $this->assertText('Donation amount must be numeric', 'Intercept non-numeric input.'); $edit['amount'] = 29; $this->drupalPost('donate', $edit, 'Donate now!'); $this->assertText('Thanks for your generosity, but we do not accept donations below $30.'); $edit['amount'] = 41; $this->drupalPost('donate', $edit, 'Donate now!'); $this->assertText('Wow, $41! Do not do this through our website, please contact us and we will discuss this over the phone.'); // Make a donation, happy path $edit['amount'] = 30; $this->drupalPost('donate', $edit, 'Donate now!'); $this->assertText('You are about to donate $30', 'The donation amount has been recorded'); } ... }

The above example is a much more complete portrait of what your site should do, and documenting everything in a failing test even before you or someone else starts coding ensures you don't forget validations and the like.

One interesting thing to note about our complete test is that sad paths actually take up a lot more effort than the happy path. There are many advantages to thinking of them first:

  • The client can be involved in making business decisions which can affect the sad path.
  • The entire team (including the client) is made aware as early as possible about sad path considerations, and the extra work they entail.
  • Nothing is taken for granted as obvious: time is set aside for sad path development.
  • The sad path becomes an integral part of your user story which can be part of the demo. Often in Agile sprint reviews, if no one has ever thought of the sad path, only the happy path is demonstrated.
  • There is less technical debt associated with sad path development: you are less likely to get a panicked call from your client once your site goes live about getting dozens of 50 cent donations when the payment processor is taking a dollar in fees.
  • Your code will be more secure: you will think about how your system can be hacked and integrate hacking attempts (and the appropriate response) directly into your test.
  • You will be more confident putting a failing test on a feature branch and handing it to junior developers: they will be less likely to forget something.
  • Thinking of the sad path can make you reconsider how to define your features: a contact form or commenting system can seem trivial when you only think of the happy path. However, when you take into account how to deal with spam, you might decide to not allow comments at all, or to allow only authenticated users to post comments or use the contact form.

Note that as in all test-driven development, your test is not set in stone. It is like any other code: developers can modify it as long as they follow the spirit of your test. For example, maybe your config page is not admin/option but something else. Developers should feel that they own the test and can change it to fit the real system.

Tags: blogplanet
Catégories: Elsewhere

Code Karate: Drupal 7 Scheduler Module

ven, 23/05/2014 - 13:23

The Drupal 7 Scheduler module can be used to easily publish or unpublish nodes as a specific time.

Catégories: Elsewhere

Deeson Online: Deeson Online's guide to getting your UX right

ven, 23/05/2014 - 12:32
Deeson Online's guide to getting your UX rightBy Mike Jongbloet | 23rd May 2014

Mike Jongbloet is Deeson Online’s new UX designer. With a background in agency and client side work, his specialities include user experience design, brand experience and information architecture.

Here Mike outlines 10 key considerations to getting your UX right: 1. Use the right tools for the job

As UX professionals we have a huge toolkit of methods to help us understand, analyse and validate. Don't get stuck in a linear approach; for each project assess particular needs and pick the best methods for the job at hand.

2. Listen to our stakeholders

One of the biggest pitfalls in digital projects is mis-aligned expectations. During the discovery phase of the project your job is to facilitate the dialogue with your stakeholders and listen to their needs; probing deeper where necessary.

3. Be creative with data sources

You can learn a lot from a good analysis of web metrics from sources like Google Analytics, but other sources such as active social channels (including competitors' channels) can unearth some great insights into the target customer base.

4. Speak to real users

Speaking to end-users is the best way of understanding who you are designing for. This can be done via focus groups, phone interviews or contextual studies. For some user bases it can even be done at the local coffee shop – an offer of free cake helps!

5. Don't assume, when you can validate

There are plenty of quick and low-cost ways to test with users, from grabbing 15 minutes of a friend's time, to using an online service. But wherever possible you should be testing to validate your assumptions.

6. Benchmark before, measure after

With your goals and objectives set, you should benchmark to create a baseline, from which you can effectively measure on completion of the project and post-launch. Benchmarking also offers the best place to identify what improvements should be focused on, moving forward.

7. Understand the problem before you try and solve it

How can you fix something if you don't understand why it's broken in the first place? The simple answer is you can't! So before you get to work on tangible deliverables like wireframes, ensure you are comfortable with your understanding of the problem at hand.

8. Socialise your findings

The research and data mining you do at the start of each project will help inform your UX deliverables, however it should also be socialised with the project team. Sharing with other disciplines will get them bought into the strategy and direction, while also helping build an understanding of UX within your organisation.

9. Overcome time and budget restrictions

In an ideal world each project would have hours of detailed research to help you design the best possible solution, but we know this is rarely the reality! Instead you need to find workarounds on a project by project basis; perhaps there are internal staff who match the demographic? Use them for interviews, or have a look at low-cost online testing solutions and use those to validate.

10. Put the effort in to keep it simple

There is a high chance that the best solution will not be the first one you come up with. Armed with the data and insights you have gathered through your research and analysis, keep iterating on your first attempt and have peers review your work. Then test it on others to aim for the best solution to make it intuitive for end users.

Have we missed anything? Let us know in the comments below!
Catégories: Elsewhere

Mogdesign: 1/3 Installation of multiple sites on Aegir

ven, 23/05/2014 - 09:55


Catégories: Elsewhere

Modules Unraveled: 110 All About Sprints at DrupalCon Austin with Joe Shindelar, Brian Gilbert, Stéphane Corlosquet, Scott Reeves and Cathy Theys - Modules Unraveled Podcast

ven, 23/05/2014 - 07:00
Published: Fri, 05/23/14Download this episodeSprints
  • What topics/areas of Drupal will be sprinted on?
    • Contribution Sprints
    • Get involved with Core - (Workshop)
    • Core Mentoring - (Sprints)
  • Who should come to the sprints?
    (short overview)
    • Why do YOU attend sprints?
    • What do you do when you want to sprint and mentor?
  • What do we need to know before coming to the sprints?
  • What do we need to bring?
    (c:where stuck)

  • Who should go to Get involved with Core - (Workshop)

  • What happens at the workshop?
  • By the end what tools do most people have set up?

    • Web Stack
    • IRC client
    • Editor ?
  • Joe what role have you had in the past?

  • What do you do to get ready to prepare/present the workshop?
  • Is it a big commitment for you?

  • Brian G what role ..

  • Brian G what big change are you excited about?
    • Funding
      • Problems with fundus
      • Paypal, if you don’t meet your goal
      • network at event for btsync
        *gittip (can’t
    • Community Tools Changes
      • (Brian G) What was involved with getting ADD and btsync ready?
      • ADD, Filesize savings, speed of installation
    • Mac users need to have XCode preinstalled (via the App Store)
      • BTSync
        • Secure, unlimited file-syncing. No cloud required.
        • It’s like a diy Dropbox, it’s not bit torrent as you may be thinking
        • Network efficiency
        • not evil

(c: prep time, DA grant)
* (Cathy) Who should go to Core Mentoring - (Sprints)
(anyone who has a local dev setup, but wants help picking out an issue)
* What happens at mentored sprint?

  • Stephane what was your role in the past?
    • floater / smaller commitment
    • ad-hoc presentations
  • What are you going to do at upcoming sprints?
  • What is it like to be a mentor? What keeps you coming back to do it again?
  • Who should mentor?
  • What does it take to be a mentor and what kind of help is needed.
  • Do you have any advice for new mentors?

  • Cathy what role have you had?

  • What are you doing this time?
    Cathy: (Stephane) What didn't you like about mentoring?
  • Any big changes you are excited about?
    (d.o, tags)
    (in public)

  • Specific Sprint Topics
    Who goes to the contribution sprints

    • Contribution Sprints
  • Final thoughts?

    • Grant allows me to come earlier than I would otherwise and ensure the network will work with btsync
Episode Links: Brian Gilbert (realityloop) on drupal.orgBrian Gilbert on TwitterCathy on drupal.orgCathy on TwitterJoe on drupal.orgJoe on TwitterScott on drupal.orgScott on TwitterStéphane on drupal.orgStéphane on TwitterStéphane Corlosquet on TwitterAustin Sprints pageCommunity Tools github pageXCode download linkBitTorrent SyncDrupal Community Tools Download InstructionsCore mentoring office hoursExtended SprintsMerlinNeeds tagsContributor task documentsMaking link to the contributor task documents automaticallyTags: 
Catégories: Elsewhere

Drupal 8 and iOS: Login to Drupal 8 with REST and http basic_auth from your iPhone

ven, 23/05/2014 - 06:20
Login to Drupal 8 with REST and http basic_auth from your iPhone

Let me start form scratch. When a user tries to access a resource on Drupal site that requires special permission or roles, a user have to login and give his identity to Drupal. Similarly if you enable REST support for a resource on your Drupal 8 site for which you want that user should give their identity first that you can choose authentication method such as http  basic_auth to cookie_auth to provide credential along with request to resource. Http basic_auth credential can be passed as base64encoded string value for “Authorization” header. 

As in REST each request should contain all necessary information to be processed if your application tries to access such resource that requires user identity you have to pass credential with “Authorization” header. So I have decide to verify user credential first and then store username and password in “keychain” on my iOS application and when ever server requires base64encoded  credential I can pass it with “Authorization” header. If user logs off then my application will delete the keychain item and also remove the credential information from future requests. In this flow it may possible that a user has logged on with your application and from Drupal site username, password combination has changed. In this case when user tries to access content which requires authentication server will response with 403 (Access forbidden) then application can ask user to login first. This is the flow for login and logout activity.

To accomplish this flow I have made one custom module that has only one route and this route it self requires authentication via http basic_auth and on successful authentication it returns a JSON object with authenticated user details. These details can be used in application. Here is controller code and routing.yml file for that module.


routing.yml file



  path: '/user/details'


    _auth: [ 'basic_auth' ]


    _content: 'Drupal\uauth\Controller\UauthController::uauthPage'

    _title: 'A simple module'


    _role: 'authenticated , administrator’

Lets first start with routing.yml file. This is new routing system due to symphony. Here first we give a machine name to a route like uauth_page: in my case followed by path (i.e is a part of URL to match with) ‘/user/details/‘. In routing.yml files some fields are required for each route like ‘defaults:’ because it offers a page call back when some one visit this route in my case it will be uauthPage() method from my controller object. In ‘options:’ I have specified authentication type as basic_auth. For more details about new routing system please read


So we have set a route which requires basic_auth to access its contents. Now what will be in the contents will be decided by controller code. Here controller uses ‘module_handler’ service from dependency injection container ( i.e just create a object of class ‘module_handler’ for me). This is new symphony way to create a module in Drupal ( fully object oriented ). Once my controller object is created a public method uauthPage() can be called, the method just uses ‘Response’ class object provided by Symphony , gathers various information about current user form the controller class and creates a JSON object and return it. Actually I should use ‘Serialization’ module provided by Drupal 8 here but I found good documentation from Symphony CMF and I read it and build this module. In future I will try to make this module to use Drupal provided modules and also support http methods in addition to ‘GET’ only. Here is link to Symphony documents



Controller Code




namespace Drupal\uauth\Controller;

use Drupal\Core\Controller\ControllerBase;

use Symfony\Component\DependencyInjection\ContainerInterface;

use Symfony\Component\HttpFoundation\Response;

class UauthController extends ControllerBase {


  public static function create(ContainerInterface $container){

    return new static($container->get('module_handler'));


   public function uauthPage(){

$account = $this->currentUser();

$userName = $account->getUsername();

$email = $account->getEmail();

$roles = $account->getRoles();

$responseArray = array('name' => $userName,

                        'email' => $email,

                        'roles' => $roles;

$response = new Response(json_encode($responseArray));


return $response;



Ok, so we are done with Drupal side. Here is a complete code for ‘uauth’ custom module just paste it to your modules directory and enable it from your site/admin/modules.

Now let’s talk about iOS SDK side. I have already mention the flow for login. To implement that flow I have created a keychain wrapper class and a user model class that is a singleton class. A top level navigation controller will check if keychain item is set for a service name than fetch that username and password and try to get user details from the route created above. If it succeeds it will push user details view controller and if not it will show an alert and pushes login view controller. If a key chain item is not there initially than it will push login view controller.

When ever user logs out keychain item will be deleted. At any time application receives 403 “Access Denied ” error keychain item will also be deleted because  it is the case when user has changed his password form the site.

Why to use keychain? Once a user has logged on to the application and if he kills the application though this logged in stat should be preserved. So anyway we need a persistence storage for a information from which we can reconstruct information about the user logged in.One may think to use NSUserDefaults. I have used the same thing before but it was not giving performance as was required because there was a problem with my coding and two animation was clashing due to swapping of view controllers and I don’t know why but this also reset my NSUserDefaults. So I read about keychain to store credentials it not only more secure but it is really a persistence storage and offers various way to store and retrieve sensitive information. I have used SGKeychain ( wrapper to understand the how to access keychain items. I would also recommend you to read Keychain Service Programming Guide and Keychain Service Reference for iOS .

Here is the code for my application try it. It uses to verify user. A test user it created on my site with username = test and password = test.

For the people who are new to Drupal 8 and Symphony I will be glad to answer your queries because it is not possible to cover each small things in this blog. Also for any question regarding my iOS application code you can mail me at

Catégories: Elsewhere

Adaptivethemes: Drupal 8 Page Manager

jeu, 22/05/2014 - 23:38

Tim Plunkett recently created a new project for Drupal 8 - Page Manager, which looks set to be the replacement for what was the Page Manager module in CTools from D7.

From the project page:

It supports the creation of new pages, and allows placing blocks within that page.
Like Drupal 7's Page Manager, it provides a concept of "page variants", each with their own selection conditions.
Additionally, it can be used to take over an existing page, like overriding /node/% to change what is displayed when viewing a node. It utilizes the core Conditions, Context, and Blocks APIs to accomplish this.

I'll be keeping a close eye on this project, especially with regards to responsive design in the eventual Drupal 8 Panels module that, at least at this stage I assume, will provide the actual layouts for Page Manager pages.

I'm pretty excited about this project and encourage anyone interested in D8 Panels and Page Manager to jump onboard and lend a helping hand.

Catégories: Elsewhere

Fred Parke | The Web Developer: Using the Modernizr library to provide graceful degradation for older browsers

jeu, 22/05/2014 - 18:36

So in my last blog post, Using the sass @for directive to generate staggered :nth-child transitions, I mentioned that the latest couple of websites I have been working on have been focusing on supporting more modern browsers and using progressive enhancement​ so that older browsers still have the same functionality - without the flourish.

Catégories: Elsewhere

Drupal core announcements: Drupal 8 module code may move to PSR-4 on May 27 (alpha 12 May 28)

jeu, 22/05/2014 - 18:06

Following the addition of PSR-4 support to Drupal 8, the next step will be to move all Drupal 8 core module code to PSR-4 (Issue #2247991).

Since this change is significant and will require the reroll of many existing patches, a potential commit window for is scheduled for May 27, to give contributors a chance to prepare for this change and update their patches before DrupalCon Austin. Drupal 8.0-alpha12 will now be released on May 28 to allow time for this change. (If the patch for Issue #2247991 is not ready by May 27, it will be postponed until after DrupalCon.)

After this change, the deprecated PSR-0 directory structure will continue to work for contributed modules, but this support will be dropped before the first beta in Issue #2247287, so you should also update your Drupal 8 contributed modules to PSR-4.

Catégories: Elsewhere

Four Kitchens: Parallel Database Reloads with Node.js and Drush

jeu, 22/05/2014 - 16:21

Have you ever found yourself working on a large Drupal site, pleased with whatever new piece of functionality you’re adding but simultaneously terrified of inevitably needing to reload the database? The thought of waiting twenty, thirty, forty, or more minutes to pull down a database is completely unacceptable and a huge waste of valuable developer time.

Our friends at Lullabot certainly have been thinking about this problem and created the mysql-parallel set of scripts to address the issue. The idea is to break a database dump and import into per-table tasks that can be run in parallel, greatly improving the overall performance of a database dump and import. I had some problems with the script though: while the general approach is certainly appreciated, it was a little trickier to use than I was happy with and I found myself writing another script to wrap mysql-parallel – because, like a good terminal nerd I’m lazy and don’t like typing out long commands or series of commands.

Wrapping mysql-parallel still wasn’t a great solution for me though, so I decided to take the idea and run with it in a different direction. The result? Two node.js modules, one general and one specific:

  1. drush-reloadp – a node.js module for reloading drush databases in parallel.
  2. drush-node – a node.js module for executing arbitrary drush commands.

Aside from being a little tricky to use, one of the issues I had with mysql-parallel is that although the dumps and imports were happening in parallel the script

  1. Does not take into account the number of processors available on the source and destination machines, which could potentially lead to unacceptable load generated during a database dump.


  1. Runs the dumps in parallel, then the imports after the dumps are finished.

drush-reloadp addresses both of my concerns.

After you’ve installed the module gobally (npm install -g drush-reloadp) you can execute it against a source and destination as follows:

drush-reloadp -s @fourkitchens.stage -d @fourkitchens.local

The -s and -d flags stand for source and destination and correspond to drush aliases which in turn will contain all the information you need to connect to the source and destination servers and databases.

When the command is executed the module will first determine how many processors are available on the source and destination servers. These values are used to limit the number of processes that will execute in parallel to avoid placing the machines under too much load that could result in task swapping.

After the number of cores are determined the module drops all of the destination database’s tables so that only clean data will be imported. Once that’s complete the module determines the tables that need to be imported from the source. Here’s where things start to get interesting: the module creates a job queue using the node.js async module. This module allows you to execute jobs in parallel without exceeding a certain limit (no swapping here!). Additionally, you can create a queue and fill it up over time, so after we start receiving dumps we immediately start adding to an import queue and begin processing those jobs. The result is a safe but fast execution of all the tasks we need to fill up our database.

After the import is complete drush updb is run against the destination site to run any locally pending update hooks and clear site caches. Some people might not like this. If you don’t open a pull request to add a flag to disable this feature.


In true node.js fashion, I separated out the underlying functionality needed for this process into as small and modular pieces as I could. The result was the drush-node module which allows node.js code to run arbitrary drush commands. There’s nothing too fancy here, the module is just running child_process.exec() with whatever drush command you’re asking for.

A nice feature of this though is that the module uses JavaScript promises (via the promised-io module) so commands can be chained together in code like this:

var drush = require(‘drush’); var group = require('promised-io/promise').all([ drush.init(), drush.exec('updb'), drush.exec('fra'), drush.exec('cc all') ]);   group.then(function (res) { console.log(res.join("\r")); }); Caveats

As mentioned in the drush-reloadp README this solution isn’t without its flaws. Consistency is sacrificed in the name of speed here. In the use cases I’ve had this hasn’t been a problem, but you will want to take this into account in the event that the source site you’re dumping from is highly trafficked – although you might want to consider not dumping directly from a active, highly trafficked site anyway.

Furthermore, this solution won’t work with Pantheon due to the unique way the DROPs architecture works. I’d be interested in ideas for expanding functionality to support Pantheon but an intermediary solution might be to have an overnight job to copy the site database onto a non-pantheon server that your team has access to. Then your team could use drush-reloadp as usual.

The hope with this is that other developers can leverage this general code to create new, interesting, and useful node scripts of their own to integrate node.js and Drupal tasks and that developers with huge databases to import will be able to spend more time coding and less time on reddit looking at pictures of cats.

Catégories: Elsewhere How to have lunch without speaking Drupal

jeu, 22/05/2014 - 09:00

Oh no, It’s lunch time!
I wonder if I’ll have anything to contribute to the conversation today. Will lunch today - like yesterday or the day before that - revolve around pull requests, Organic groups, migrate, scrum, code reviews, modules. Boring.
If you share the same feeling reading the above lines, this blog post if for you.

Geeks having a spontaneous reaction to a new version of a Drupal module. I love those guys!

Don’t get me wrong - I love my job and I love my co-workers as well. It’s just that every time they talk about these things it makes me wanna stand up on our designer kitchen chair and shout:
My name is Orit and I am not a Drupal geek!

I have never developed any module in my life, didn't contribute anything to OG nor have I never requested Brice or Amitai to give me a scrutinizing code review. So here are some tips:

Continue reading…

Catégories: Elsewhere

OpenConcept: Translating user-entered strings in D7

mer, 21/05/2014 - 21:30

The Internationalization suite of modules do a pretty good job of making everything translatable in Drupal 7. But, if you're writing a module that stores its data outside variables or entities, you might notice a few gaps.

On a recent project, I noticed that field display settings (field formatter settings for those familiar with the Field API) are not translatable by default. In many cases, this is fine because the field settings in core modules don't make sense to translate: for example, the number of characters to trim a summary at or the image style to use.

Never use t($user_entered_string)!

It's tempting to solve this problem by passing the variable through t() as you're outputting it (e.g.: $label = t($settings['label'])), however doing so is a bad idea!

Why t($variable) is usually a bad idea

To quote the documentation for the t() function,

You should never use t() to translate variables, such as calling


There are a few reasons for this:

  • In addition to actually translating text at run-time, the t() function is also used by text-extraction routines to find text that needs to be translated, and build databases of text to be translated for translation teams.

    Both the Internationalization's built-in string translator and the Translation template extractor module (which powers the Drupal Translations site) ignore calls to t(), whose first argument contains any variable (e.g.: t($var), t($var . 'text'), etc.): these won't even show up as being available to translate!

  • The t() system doesn't support updates to existing strings. When user data is updated, the next time it's passed through t(), a new record is created instead of an update. The database bloats over time and any existing translations are orphaned with each update.
  • The t() system assumes any data it receives is in English. User data may be in another language, producing translation errors.

The only case in which variables can be passed safely through t() is when the string in the variable will be passed through t() elsewhere.

Why t($user_entered_string) is a security risk

To quote the t() function documentation again,

It is especially important never to call


, where $user_text is some text that a user entered - doing that can lead to cross-site scripting and other security problems.

For example, a malicious translator could enter HTML in their translations (a cross-site scripting (XSS) attack).

Introducing i18n_string()

So, what is a module developer to do? As it turns out, the Internationalization project's String translation sub-module (i18n_string) has a function named i18n_string(), which makes it easy to store and retrieve translations of user-entered strings with only minimal changes to your module.

Remembering your keys

To ensure strings get updated, not orphaned, i18n_string() requires a $key parameter that uniquely identifies that instance of the string to store and load the string.

For example, if the string is always displayed the same way, a simple key will suffice (like a variable name). However, if the string has variants, like a block title (each block could have a different title) or a field formatter setting (each content type could have different settings for each of its display modes; and there could be more than one field of that type in a content type), you'll want to construct the key from the identifiers that make that variant unique (e.g.: blocks are uniquely identified by module and delta; field formatter settings are uniquely identified by entity, bundle, view mode and field name).

Registering and translating strings

The i18n_string() function has two operations: registering a user-entered string when it's saved (this is referred to as updating the string in the API) and translating (retrieving) the string when it's displayed.

To register a string, call:

i18n_string($key, $value, array('update' => TRUE));

... where $value is whatever the user entered. Note you should still store $value somewhere so you can provide a default if the user doesn't have i18n installed (more about this later).

Note that it's really easy to insert this call into your existing code: you don't have to change the way your module already stores / retrieves the setting.

To translate a string, call:

$string_to_display = i18n_string($key, $value);

... where $value is whatever the user saved earlier. As with any user-entered string, make sure you've check_plain()ed or filter_xss()ed it

Again, note that it's really easy to insert this call into your existing code.

Best practices

Currently, the i18n_string() function isn't part of D7 core (although it exists in the form of translatable configuration in D8 core), you have to ensure i18n_string() is available before you call it, otherwise you'll get "Call to undefined function" errors.

The documentation on using the i18n API from other modules suggests wrapping calls to it in functions which check if the function has been defined and calls it if it does (or acts as if nothing happened if it doesn't exist):

function _mymodule_translate($name, $string, $langcode = NULL) {
 return function_exists('i18n_string') ? i18n_string($name, $string, array('langcode' => $langcode)) : $string;

function _mymodule_translate_update($name, $string, $langcode = NULL) {
 return function_exists('i18n_string') ? i18n_string($name, $string, array('update' => TRUE, 'langcode' => $langcode)) : FALSE;

Note that the translate function above returns its $string parameter if i18n_string() isn't available.


The i18n_string() function makes it easy to bolt translation on to existing code without changing the way your module works.

If you want to see an example of how I solved the field display setting translation problem for the Entity registration module, you can see my patch at #2234915: Registration link text (field formatter label) is not translatable.

Topic: Services: 
Catégories: Elsewhere

AGLOBALWAY: Colour contrast for accessibility: making your site readable

mer, 21/05/2014 - 20:20

One of the trends in minimalist web design is to choose fonts and colours that are small thin, or light. Understandably, this makes for a clean look and adds subtlety to your design. Despite the visual appeal, this approach can create some problems with accessibility.

As part of the small (though not insignificant) segment of the population that is colour-blind, I have particular difficulty reading text styled in this manner. The WCAG Standard describes the minimum contrast ratio for text that is less than 18 point (if not bold) and less than 14 point (if bold) as 4.5:1. The linked above provides some example scenarios and technique suggestions for ensuring that this contrast ratio can be achieved, as well as some resources to guide you in your development.

One thing that is easy to do is to when developing your site is to disable images using Firefox developer tools (or something similar), and see what your text looks like. Often we will have white text on a dark background - but if that background image disappears the text can be impossible to read. Simply adding a background colour to your text to match your image colour can prevent this from being an issue when images are turned off. Other methods like shadows or similar effects can also help to achieve readability.

Remember, keep your text at a readable size (no more tiny text!), and turn up the contrast. Many people have visual impairments of some form or another, and we want everyone to be able to read our content.

Bonus: if you enjoy playing around while you work, this is one of my favourite tools for checking your colour contrast.

Tags: drupaldrupal planet
Catégories: Elsewhere

Palantir: Palantir @ DrupalCon Austin

mer, 21/05/2014 - 19:38

It’s that time of year again: DrupalCon in the US! We’ll be headed to the great state of Texas – Austin, specifically – and we’re incredibly excited to get things rolling. Why? It’s the sharing of ideas, the culture, the community, and the fun – it’s like an enormous think-tank filled with like-minded, interesting individuals, from which new methods emerge and inspiration flows. Will you be there? Let us know via email or on Twitter, or in the comments.

We’ve set up shop at booth 215, across from the Drupal Association and the Commerce Village (and right near one of the main coffee stations, thankfully). We hope you stop by and say hello, grab a button and sticker, play a little Palantrivia while you sip on a coffee, and hang out with the Palantiri that will inevitably be congregating at our booth throughout the week.

If we don’t catch you on the show floor for some odd reason, we do hope to see you during post-con hours – like at Trivia Night, of which Palantir is a proud sponsor!

Of course, let’s not forget the point of DrupalCon: sharing and learning. To this end, we have 11 Palantiri headed to the Con this year, some of whom are leading sessions. Here’s who’s going, and a rundown of sessions of interest: Sean Buscay, Kelsey Bentham, George DeMet, Larry “Crell” Garfield, Tom Jones, Steve Persch, Ken Rickard, Shawn Smith, Andrea Soper, Ryan Wagner, and Chris Zietlow.

Larry Garfield

Ken Rickard

Sean Buscay

Andrea Soper

Steve Persch is looking forward to…

We’re also quite proud to be Gold Level sponsors of the conference this year, in addition to sponsoring the aforementioned, mind-bending Trivia Night. We hope to see you around the convention and beyond.

What are you excited for at DrupalCon this year? Let us know in the comments.

photo: Michael Schmid - CC BY-SA 2.0

Catégories: Elsewhere

Drupal Association News: Calling All Design Firms: DrupalCon needs you

mer, 21/05/2014 - 17:58

The Drupal Association is seeking two creative and innovative design partners to create the web and print designs for the 2015 and 2016 DrupalCon events. We’re looking for people who understand that each DrupalCon is a singular expression of the Drupal community, DrupalCon location, software innovation, and extreme nerdiness, and know how to turn this into compelling designs that are functional, fun, and make people look twice.

DrupalCon events convene thousands of people from the diverse Drupal Community - including coders, site builders, content editors, business people, themers, and more. For a week, these people come together to drain a city of all its coffee and fill the void with  energy, companionship, and code unmatched by any other tech community. Part SxSW, part DreamForce, and part college dorm room, DrupalCons are a signature part of the Drupal experience.

Design is an important part of the DrupalCon experience. Through design, we are able to:

  • Showcase the community in which the DrupalCon is held, highlighting known, and not so known, gems without subverting or subjugating the Drupal identity.
  • Illustrate the beauty of Drupal for web sites. DrupalCon web sites should push the boundaries of Drupal design.
  • Create a sense of community connection. DrupalCon t-shirts and pins are collectors items, worn by the folks who proudly show off their participation.
Project Elements

DrupalCons are not small undertakings. Your designs will need to work in a variety of contexts and settings, from giant 12 foot banners to 150 pixels square web badges. Following is a comprehensive, though not exhaustive, list of elements to be delivered:

  • Conference logo, web and print ready formats
  • Coming soon! splash page (prior to official site launch)
  • Conference web site theme (but you don’t have to build the site, we’re on that)
  • Web badges for sponsors, attendees, and other stakeholders
  • Social media icons and branding
  • Newsletter banners and other digital promotion images
  • Conference venue signage, including banners, etc.
  • Various merchandise and branding elements
  • Conference program guide
  • Sponsorship guide
  • Style guide

There’s one thing you DON’T have to do: build the website. The Drupal Association will lead the development of the website from COD. Our Design Partner will be heavily involved in applying the new design to the website as a Drupal theme. Knowledge of COD and Commerce will be extremely helpful here.


We don’t want to leave you to wander the wilderness alone, so we’ll be providing lots of guidance along the way, but our goal is to stay out of your way as much as possible and let you create compelling, fun, and memorable work. That said, there are a few things you’re going to want to be prepared for:

  • Working with a committee of local team members. We don’t run DrupalCons by ourselves. Our Local Team committee is going to be deeply involved in developing the identity of the conference. But don’t worry - they don’t all have to sign off on every design element.
  • We expect extreme comfort in web and print production processes. We make a LOT of stuff for this conference, and understanding printing processes will allow you to maximize our print budget while pushing the boundaries of cool.

Budget for our North America, 2015 and Europe 2015 DrupalCons are each fixed at $25,000 per event. Third Cons (Cons to be held outside of North America and Europe in locations to be determined) and 2016 Cons, depending on location, will have different budgets based on estimated event size and scope.  The design company will receive public recognition on the site via footer credits and volunteer credits, and a Bronze level booth at each event, which includes 2 tickets.


Starting in 2015, the Drupal Association will be producing 3 DrupalCons each year.  To make the process smoother, we are going to stagger our designers.  We are currently looking for designers as follows:

  • Designer 1: North America, 2015 and 3rd Con to be determined in 2016
  • Designer 2: Europe, 2015 and North America 2016

We expect to complete firm selection for Designer 1 by late-June And Designer 2 by mid-July. We intend to conduct a selection process that is better suited to engage and evaluate the relative merits of creative professionals. Firms that intend to bid on this project should state their intent to bid (contact info below). We will then schedule a presentation, where our team can get a sense of you, your process, and your portfolio. A round of Q&A follows, leading to our selection process, after which we will announce selections. Then, we’ll work on a final round of negotiations and a contract. If your firm is not selected we will take the time to explain why.

Firms that intend to bid should email Stephanie Torres (contact information below) no later than Friday, June 13, 5pm PST.

Contact Information

Stephanie Torres (email)
Community Program Manager, Drupal Association
+1 503-915-9073

Catégories: Elsewhere

Fred Parke | The Web Developer: Using the sass @for directive to generate staggered :nth-child transitions

mer, 21/05/2014 - 16:01

Older browsers be damned!

The latest couple of Drupal websites I have worked on have been incredibly fulfilling to me as a front-end developer in that they aren't bogging themselves down with ridiculous old browser support.

We are using progressive enhancement of course, so these browsers still have the same functionality, but don't get to have all the sexy flourishes. These are mostly done using CSS3, something that if your browser doesn't support, you probably don't deserve anyway.

Catégories: Elsewhere

Tigerfish: White House contributes APIs, stages hackathons & runs on Drupal

mer, 21/05/2014 - 14:43
Director of new media technologies at the Executive Office of the President of the United State of America Leigh Heyman was recently reported to be the man behind all the modern interactive media delivered during Barack Obama's last 'state of the union' a

When he's not making sure President Obama's "social footprint" is impressive and impactful, Heyman can be found explaining how the White House has embraced open source technologies as part of its wider remit to digitise its activities.

Heyman recently spoke at a conference in South Carolina to explain how has been working with more open technologies.

Most interesting of all perhaps is that this presidential IT team is now moving towards more open and transparent government with activities including:

Blogs: Drupal PlanetTags: Blogging
Catégories: Elsewhere

Code Karate: Using Views with the Entity Reference module in Drupal 7

mer, 21/05/2014 - 13:50

If you want to learn how to use Drupal 7 Entity Reference fields with the Views module you have come to the right place.

Catégories: Elsewhere