Feb 03 2014
Feb 03


As someone working on some drupal site you often want to understand what happens on a specific site. This blog post will describe a tool which helps to understand the site faster and easier.

One example you wanna see are the executed database queries. In Drupal 7 we had the wonderful Devel module which showed a list of executed database queries below the page but there are way more information you might want to know:

  • PHP Configuration
  • The needed time and memory
  • List of enabled themes/modules
  • Routing information (aka. hook_menu in D7)
  • The requested cache/Key-Value data
  • Information about the Request raw data

Symfony has a nice toolbar at the bottom
which stores this information, shows it and make it available as separate page
for additional research.

The founder of symfony (fabpot) gave me some
initial version of a drupal integration. Sadly Luca Lusso started independent on a version, so we merged the code together and continue
on https://drupal.org/node/2165731.

So here is out it looks like (click images for larger version):

so you see quite a big amount of integrations already. Let's list what we have at the moment:

  • PHP Config
  • Request
  • Forms
  • Database
  • Modules/Themes
  • Routing
  • Cache
  • State
  • (Config: There is a working branch relying on a core patch: https://drupal.org/node/2184231)
  • Your ideas!

You could certainly ask yourself whether this is a total replacement of the devel module. There is an
ongoing discussion at https://drupal.org/node/257770 whether to use the symfony toolbar/an alternative php one.

Please try out the module on Drupal 8 and come up with more ideas and help us.

Sep 11 2013
Sep 11


There has been a lot of blog posts how to use the new hook_menu/page callback equivalent in Drupal 8 (http://effulgentsia.drupalgardens.com/content/drupal-8-hello-oop-hello-… for a great reference) on that.

On the other hand these posts don't cover how the routing system actually works, so here comes a series of posts, how the routing system works in Drupal 8.

The basic part.

The really basic idea behind the symfony control flow is the following:

  • A HTTP Request comes in.
  • The Request is converted into a response.
  • The Response is send.

That's so much for the first post but there will be more over the time.
Please ask questions so we can figure out how to put that into a proper piece of documentation.

Apr 15 2013
Apr 15


Since http://drupal.org/node/1567500 Drupal 8 started to use PHPUnit as it's unit test framework. One advantage of PHPUnit is that there are tools around which support it already.

One example is phpstorm
which is a great IDE for php developers.

This blog post describes how you can setup to run phpunit in phpstorm.

Step 1: Create a new run configuration

You start by clicking on the arrow in the UI and choose "Edit Configuration". (See Screenshot).

Step 2: Create a new phpunit configuration

You continue with clicking on the green "plus" on the left top
corner. There you choose phpunit.

Step 3: Configure it properly

The tricky part is to configure it properly. Just use "defined in the configuration file", specify the right location and add the testrunner code. (For lazy people, just use the code below :) )


-d auto_prepend_file=/var/www/d8/core/tests/bootstrap.php

Step 4: Profit!

From now on you don't even have to leave your IDE anymore just to develop stuff. Another reason why we should start to write more and more tests in PHPUnit.

Please comment and share other tips with phpunit/phpstorm in the comments.

Nov 22 2012
Nov 22


Today is the 22th of november so there are 8 days left to get features into drupal core until feature freeze,
so just today went so many changes in that you could write a whole book with just that.

Here is a random list of changes from today:

  • Created a new history module which records which content has been read by which user.
  • Support to create the database in the Installer.
  • Totally new redesign of the toolbar, which has a proper mobile/responsive support, see screenshot.
  • Basic REST support to get entities.
  • A diff engine in core, which will allow to diff on revisions and configuration.
  • Adds a basic version of views bulk operations into core.
  • Implement generic access on entities.
  • Fully redesigned module page, see screenshot.
  • Primary buttons on forms, which allows you to specify the important action (similar to MacOSX, see screenshots)
  • Many more

Everyone contribution to drupal now really ROCKS! This is an amazing time.

Sep 11 2012
Sep 11

Since Drupal 6 and Drupal 7 a lot of popular modules like ctools, rules and views (and probably many more) had some kind of way to extend it's functionality by writing so called plugins. The idea was to swap out certain behavior of your system by another plugin of the same type.
For example you can replace the output/style of a view to a fancy slideshow by choosing another style in the user interface.

There were multiple "standards" how to create such systems,
so for different modules you always had to learn a new way,
made different mistakes and basically wasted a lot of time.
Therefore in d8 one goal was to unify them and make it
much easier to use.

A plugin in d8 will be always some kind of php-class which are part of a namespace, which correlates with the folder/filename. This sounds maybe complicated but let's have a look at an example.

Assume you want to add a new style plugin to views you would in d8

  • Create a file called Example.php in the folder your_module/lib/Drupal/your_module/Plugin/views/style
  • At the top of the file you define the namespace:

    namespace Drupal\your_module\Plugin\views\style;

To be able to tell drupal of your plugin, you use Annotations,
which are basically comments in your php code.

They contain metainformation attached to
the plugin directly. You can compare this basically with the info hooks in d7:

// Add the below used views baseclass.
use Drupal\views\Plugin\views\style\StylePluginBase;
// These two lines are required to scan the code for the plugin.
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;

// The actual annotation starts:
 * @Plugin(
 *   id = "style_example",
 *   title = @Translation("Just an example style plugin to explain the plugin system"),
 *   additional_info = "Some random information"
 * )
class Example extends StylePluginBase {

That's all you need to start writing your plugin. Just have a look at the attachment for everything that is needed.

Now we learned how to write a views plugin, but you will be able to apply this to nearly everything in drupal8 for example a block plugin (the d8 way to write custom blocks).
You add the file with a class of the right namespace and add the annotations, probably clear your caches and be happy ... see screenshot.

I neglegted some internal things of the plugin system which either will let you explode your brain or feel really excited.
A long documentation of the new system can be found under: http://drupal.org/node/1637614

Thanks for the scotch and wscci initiative for the implementation of such a flexible system.

AnhangGrösse 2.88 KB
Jan 05 2012
Jan 05

One major problem with using panels for all pages is
that many modules doesn't have built in integration
for panels. A solution to this problem is to write an
integration for the module to get the full control but
this sure needs some time. So Swentel wrote a
module which allows to take over any existing page, yes any!

To use it start on admin > structure > pages
and "add an existing page". Let's put the Panels configuration page into a panel, so input something into the search paths, see image.

Once you have done this go back to admin > structure > pages,
there you see "pm_existing_pages-{name you choosed above}"; enable it
and configure the panel.

One important pane you should know is under "existing page" -> "existing page":

That's all, see

AnhangGrösse 33.9 KB 15.19 KB 44.74 KB
Nov 28 2011
Nov 28

Last weekend, between November 25th to 27th,
the awesome guys from Comm-Press hosted a views (code) sprint in their new office .

At first I was a little bit sceptical. Can you scale a codesprint up to 20 people?

But they proved it's definitive possible!
At Saturday everyone said hello to each other and Karsten started to throw in some ideas what people could do. It turned out there where enough tasks for everyone, such as:

  • conduct a usuability test
  • develop some UI ideas based on the UX test
  • provide regex support for both string and numeric filters
  • port views_cloud to d7
  • write a views integration for taxonomy_entity_index
  • improve the webform views integration
  • issue triage, more about this might be added later
  • review the existing documentation and start to improve it
  • go through the "needs review"/RTBC patches and reduce their numbers

 Review des Views Sprints

Quite some people started with the issue triage aka rock in the issue queue.
For this, Karsten gave a really good explanation on how to act in the issue queue.
After that, around 10 people started to work on it, and the outcoming results blew my mind: they worked
on 250 isses within two days (c.f. http://drupal.org/project/issues/views?page=4&status=All ) accompanied by around 50 issues in several other issue queues. This impressive figures don't even include the work of the documentation and the UI team, because they did more kind of a preperation work for future issues.

The enviroment was incredible: We were provided with food, something to drink and even some nerf guns! Furthermore, special thanks go to @freudenreich_m and @ralfhendel for organizing the famous German hacker elixir "club-mate" at Sunday morning.

The total statistics:
* ~300 issues
* 60 commits directly to Views and 40 to other projects/sandboxes etc.
* 5 Nerf guns

Thanks for all people which took part or were involved via sponsoring etc.
The drupal community is unique!

There were also some remote part-time sprinters: das-peter, damz and maybe other people I forgot to mention (I apologize if that might have been the case).

Oct 11 2010
Oct 11

On websites with a lot of users and especially a lot of nodes a lot of queries can kill your site performance.

One central problem is the usage of node access. It's recommended to avoid it as long you can, but there might be other ways to get around some problems. Here is one specific example which is quite interesting.

The goal of the view was to show the X latest users together with it's profile picture and some additional stuff. The site used content profile so a view with the base_table "node" was used. Sadly this query was horrible slow so views caching was set to a long time(using views caching is a easy and good improvement and is highly recommended).

When the cache had to be rebuild the query was still slow. So instead of using node as base table choosing user as base table made it. This improved the query time by the factor 10, because of several reasons:

  • no node access system is used(which wasn't needed on this view)
  • less rows has to be joined

In views3 recently a patch landed which allows to disable node access on a certain view: http://drupal.org/node/621142

Aug 29 2010
Aug 29

Many people ask is views 3 ready for production. Here is an answer

A quote from earl miles

Right now I only recommend Views 3 in production if there's a Drupal expert on staff/call, mostly due to the fact that a lot of modules are not yet Views 3 compatible and that will really screw you.

Aug 25 2010
Aug 25

Recently we had the following error message on the site:

warning: Invalid argument supplied for foreach in taxonomy.module...

So what's the problem. The node variables seems to be empty so
this fails. So the main question is way is this variable empty here.

After short debugging it was possible find out that the uid of the node table is not existant. This happened because the user table was changed. Once you have this node_load fails. This is quite a wtf.

To fix this you have to

  • Find out the nodes without an author:

    SELECT n.nid FROM {node} n LEFT JOIN {users} u ON u.uid = n.uid WHERE u.uid IS NULL;
  • Set a author for this node:

    UPDATE {node} SET uid = 3 WHERE nid = 123;

Once you have this the problem will go away.

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