Skip to Content

Planet Drupal

Syndicate content - aggregated feeds in category Planet Drupal
Updated: 1 day 23 hours ago

InternetDevels: Using Neo4j graph database: part 1

19 January 2016 - 12:56am

Let's keep getting the most useful web development tips from InternetDevels developers.
Here's the first blog post about Neo4j in which you will learn the basics.

Read more
Categories: Drupal Writing your first Drupal service

19 January 2016 - 12:48am

We got a basic understanding of what a Drupal service is previously. Let's put that into action by creating a simple service in Drupal 8. Take note that this service what we are about to create doesn't do anything useful yet, and is written with a pedagogical purpose in mind.

This service will list a few best selling books from Leanpub. First, to deal with all the boilerplate of creating a module using DrupalConsole. Never ever write a module from scratch by hand!

$ drupal generate:module // Welcome to the Drupal module generator Enter the new module name: > techbooks Enter the module machine name [techbooks]: > Enter the module Path [/modules/custom]: > Enter module description [My Awesome Module]: > My first service Enter package name [Custom]: > Enter Drupal Core version [8.x]: > Do you want to generate a .module file (yes/no) [no]: > no Define module as feature (yes/no) [no]: > no Do you want to add a composer.json file to your module (yes/no) [yes]: > no Would you like to add module dependencies (yes/no) [no]: > no Do you confirm generation? (yes/no) [yes]: > yes Generated or updated files Site path: /var/www/html/drupal-8.0.2 1 - modules/custom/techbooks/

The next step is to write a service configuration in our module. This configuration dictates how the service class will be initialized and how it can be called from code. The Drupal convention is to write this in a <module-name>.services.yml.

services: techbooks.listbooks: class: Drupal\techbooks\ListBooks

The services configuration part begins with services: and lists all the services provided by our module. In our case, we have just one service. We give it a name, techbooks.listbooks. Its a good idea to namespace services, which can be done by prefixing a namespace name followed by a dot. The class tells Drupal what class to call to create the service. This should be the fully qualified name of the class. The services YAML file can also store any service related information as well. All the book related data like title, author etc. is stored in the same file.

parameters: leanpub.booklist: - {title: 'The Elements of Data Analytic Style', author: 'Jeff Leek', url: ''} - {title: "Build APIs You Won't Hate", author: 'Phil Sturgeon', url: ''} - {title: 'Easy Laravel 5', author: 'W. Jason Gilmore', url: ''} - {title: 'Ansible for DevOps', author: 'Jeff Geerling', url: ''} - {title: 'Principles of Package Design', author: 'Matthias Noback', url: ''} - {title: 'Modernizing Legacy Applications In PHP', author: 'Paul M. Jones', url: ''} - {title: 'Front-End Fundamentals', author: 'Carwin Young, Joe Fender', url: ''} - {title: 'Talking with Tech Leads', author: 'Patrick Kua', url: ''}

We shall come back in a bit on how we will use this data. Note that creating a service is also mostly boilerplate code. Hence, we can avail Drupal Console to do the job for us and fill out the custom details.

$ drupal generate:service // Welcome to the Drupal service generator Enter the module name [techbooks]: > Enter the service name [techbooks.default]: > techbooks.listbooks Enter the Class name [DefaultService]: > ListBooks Create an interface (yes/no) [yes]: > no Do you want to load services from the container (yes/no) [no]: > no Do you confirm generation? (yes/no) [yes]: > yes Generated or updated files Site path: /var/www/html/drupal-8.0.2 1 - modules/custom/techbooks/ 2 - modules/custom/techbooks/src/ListBooks.php Rebuilding cache(s), wait a moment please. [OK] Done clearing cache(s).

We have defined a service, but haven't exactly told Drupal what it does. For this, we have to flesh out the ListBooks class inside the module's src/ directory.

namespace Drupal\techbooks; /** * Class ListBooks. * * @package Drupal\techbooks */ class ListBooks { public function getBooks() { return t('All your books will be listed!'); } }

Once you have defined this service and enabled the module, you can use it anywhere in your code by invoking the service:

$book_list = \Drupal::service('techbooks.listbooks')->getBooks();

Drupal creates an instance of your listbooks service and fetches that instance on every call to the service. It effectively calls getBooks() of that instance, which returns a string. Let's add a route for listing books.

If you hit /techbooks in your browser, you should get this:

Not a lot happening there. Let's actually list some books!

Services can take in parameters while initializing. They are just plain PHP classes in disguise after all! Let's pass the book list we defined earlier in the yaml file as a parameter to the listbooks service.

services: techbooks.listbooks: class: Drupal\techbooks\ListBooks arguments: ["%leanpub.booklist%"]

The only change is the arguments property. We refer to the leanpub.booklist property as the argument. The enclosing % is to indicate that it is an internal variable/property. Also, notice that we wrap the argument within quotes, failing which it will be interpreted as a literal string. For example, arguments: [leanpub.booklist] will send the string "leanpub.booklist" as argument to the ListBooks class, which is not what we want!

Let's modify the ListBooks class to take in the arguments.

class ListBooks { public function __construct($books) { $this->books = $books; } public function getBooks() { return $this->books; } }

Changing the controller code accordingly,

public function bookList() { $book_list = \Drupal::service('techbooks.listbooks')->getBooks(); $render = ''; foreach($book_list as $book) { $render .= '<div><span>Title: ' . $book['title'] . '</span></div>'; $render .= '<div><span>Author: ' . $book['author'] . '</span></div>'; } return [ '#type' => 'markup', '#markup' => $render ]; }

Now, our /techbooks page actually lists books!

It doesn't look pretty and all, but hey, we just created our first Drupal service :)

You can grab the code for this example from github and checkout the basic-service tag to see it come to life.

Resources Drupal, Drupal 8, Drupal Planet
Categories: Drupal My Drupal Story – How I came for code and stayed for community

18 January 2016 - 8:57pm
As taglines go, I know this is heavily cliched but it happens to be true to every letter. I can't think of any better way to describe the overall Drupal ecosystem as "Come for the code, stay for the community."
Categories: Drupal

DrupalCon News: Get ready for DrupalCon New Orleans

18 January 2016 - 4:37pm

Where y’at! The DrupalCon New Orleans site is here and ready for you to submit your proposals for trainings, scholarships, and grants.

Happening in the Big Easy this May, DrupalCon New Orleans is going to be a colorful, exciting expression of the Drupal Community’s diversity, creativity, and fun. New Orleans is a city unlike any other, and this DrupalCon promises to be exceptional. Join us for the first North American DrupalCon since the release of Drupal 8 for a healthy dose of culture, history, and all things Drupal blue.

Categories: Drupal Migrate to Drupal 8 from a custom site

18 January 2016 - 2:16pm
Migrate is now included in the Drupal core for making the upgrade path from 6.x and 7.x versions to Drupal 8.

Drupal 8 has two new modules :

- Migrate: « Handles migrations »
-Migrate Drupal : « Contains migrations from older Drupal versions. »
Categories: Drupal Inline Entity Display

18 January 2016 - 2:16pm
Handle referenced entity fields directly in the parent entity
Categories: Drupal

OSTraining: Use Openlayers to Build Drupal Maps

18 January 2016 - 1:25pm

Openlayers is a Javascript library that allows you display maps from multiple different sources. It works with Mapquest, Yahoo Maps, Stamen, Google Street Map, Open Street Map and more.

Openlayers' flexibility makes it a very useful option. For example, an OSTraining member wanted to use Openlayers because he needed to build a site in China, where Google Maps is blocked.

Categories: Drupal

Wim Leers: Performance Calendar 2015: "2013 is calling: are CMSes fast by default yet?"

18 January 2016 - 12:35pm

This year, Performance Planet did an advent calendar again, just like the last few years. I also contributed an article — what follows is a verbatim copy of my “2013 is calling: are CMSes fast by default yet?” article for the 2015 Performance Calendar that was published exactly a month ago.

Two years ago, I wrote about how making the entire web fast is the real challenge. How only the big few companies are able to have very fast websites, because only they have the resources to optimize for performance. Many (if not most) organizations are happy just to have a functioning, decent looking site.

In that article, I said I thought that if we made the most popular CMSes faster by default. That would go a long way to make the majority of the web faster. Then less technical users do not need to know about the many arcane switches and knobs just to get the intended performance. No more “oh but you didn’t set it up correctly/optimally” — or at least far less of it.

Drupal 8: fast by default on many fronts

Since that article two years ago I’ve been working with >3300 other contributors to get the next version of Drupal done. Drupal 8 was released a month ago and is much faster by default.

All of the following changes improve perceived performance and Drupal 8 has all of them enabled by default:

… and for those last three fast defaults, each of which does caching: they don’t ever serve stale content.

Instantaneous, optimal invalidation thanks to cache tags. Lots of interesting possibilities with Drupal 8’s cacheability metadata.

Also, some CDNs already support cache tags. Which means instantaneous invalidation of content even when served from a CDN.

More fast defaults coming in minor Drupal 8 releases

We also paved the path for more optimizations to land in upcoming minor versions:

  • automatically use BigPipe for the dynamic/personalized/uncacheable parts of the page, have the initial part of the page sent immediately, thanks to the aforementioned partial page caching
  • JavaScript minification3
  • responsive images: already supported but not enabled by default
  • HTTP/2 server push of assets: we already have a dependency graph of all assets — we’re mostly blocked on HTTP/2 servers actually supporting this.

There are of course many additional defaults that would help Drupal 8 be even faster by default, such as:

  • optimal image compression
  • load JavaScript asynchronously
  • automatic inlining of critical CSS
WordPress 4.4: responsive images by default

WordPress has made one significant change to improve performance: responsive images are enabled by default since the 4.4 release a week ago. Sadly, that’s the only significant WPO change in 2 years. (Six significant releases were made: versions 3.8 through 4.4.)

Joomla 3.x: status quo

Unfortunately, no significant steps forward have been made by Joomla to make it fast by default. 3.3.0 made the routing system faster and continued the conversion from MooTools to jQuery, which hopefully translates to less JavaScript being loaded. (Two significant releases were made: 3.3.0 and 3.4.0.)


So, Drupal has put a lot of effort into making version 8 fast by default. As Drupal 8 is rolled out, hundreds of thousands of sites will become faster.

Hopefully other CMSes (and frameworks) will follow.

Let’s make the entire web fast!

  1. Functionality that is implemented in JavaScript for authenticated users is applied on the server side once and cached for subsequent visits. 

  2. Yes, for HTTP/2 that will make less sense … but at least today’s HTTP/2 servers and browsers still benefit from aggregation

  3. To do JavaScript minification in compliance with the GPL is not trivial

Categories: Drupal

Acquia Developer Center Blog: Minimizing maintenance time while updating thousands of Acquia Cloud Site Factory sites

18 January 2016 - 10:22am
Peter Wolanin

Note (January 2016):  While this blog post was originally written about (originally published April 06, 2010), the same basic strategy for updating sites has continued to be used in the Acquia Cloud Site Factory (ACSF) platform that emerged from it. Some of the very specific details in the original post are outdated (for example, we now use git instead of svn), but the strategy of using two docroots with different code versions and two different vhost ports to choose between them is how ACSF still works to update sites.

Tags: acquia drupal planet
Categories: Drupal

Drupal core announcements: Drupal core security release window on Wednesday, January 20, 2016

18 January 2016 - 10:08am
Start:  2016-01-20 (All day) America/Chicago Organizers:  catch xjm David_Rothstein Event type:  Online meeting (eg. IRC meeting)

The monthly security release window for Drupal 6, 7, and 8 core will take place on Wednesday, January 20.

This does not mean that a Drupal core security release will necessarily take place on that date for any of the Drupal 6, 7, or 8 branches, only that you should watch for one (and be ready to update your Drupal sites in the event that the Drupal security team decides to make a release).

There will be no bug fix or feature release on this date. The next window for a Drupal core patch (bug fix) release for all branches is Wednesday, February 3, 2016. The next scheduled minor (feature) release for Drupal 8 will be on April 20, 2016. This is the second-to-last security release window before the Drupal 6 end-of-life on February 24.

For more information on Drupal core release windows, see the documentation on release timing and security releases, and the discussion that led to this policy being implemented.

Categories: Drupal

Mediacurrent: Contrib Committee status review for December 2015

18 January 2016 - 7:16am

The last month of the year was rather slow with many of us taking vacation time to spend with our respective families.

Our clients love to contribute to open source

Along the way a few of our clients needed some work that we were able to contribute back:

Categories: Drupal

OpenLucius: Update OpenLucius | January 2016

18 January 2016 - 3:57am

First of all: we are out of RC, we have a 1.0 release!

Furthermore, as we continue our journey in 2016, here's the overview of updates we just pushed.

Categories: Drupal

DrupalCon News: DrupalGov Summit at DrupalCon Asia

18 January 2016 - 3:11am

In August 2014, the government of India announced the bold and far-reaching Digital India policy. This ambitious initiative aims to bring about profound digital transformation in all aspects of governance and prepare India and its citizens for a knowledge-driven future.​

The three goals of Digital India are:

Categories: Drupal

Jim Birch: Submit your sessions for Midcamp 2016 - Midwest Drupal Camp in Chicago

18 January 2016 - 2:20am

MidCamp is returning to Chicago, Illinois on March 17th through the 20th, 2016.  We will be returning to the University of Illinois at Chicago, this time, on the west side of the campus.  MidCamp is looking for people to speak to our Drupal audience! Experienced speakers are always welcome, but our camp is also a great place to start for first-time speakers. 

We are expecting more than 300 people at the event this year, all in a wide variety of skill levels and disciplines.  We are looking for sessions that are targeted towards beginner through advanced, in 30 minute and hour long formats, that can cover a wide variety of topics in and around Drupal.

Find out more information, please visit:

Read more

Categories: Drupal

Kristian Polso: Crawling the top 15,000 Drupal websites: 2016 edition

18 January 2016 - 12:40am
An update to last year's blog post, this post is about crawling the top 1,000,000 sites from Alexa and determining their CMS and Drupal versions etc.
Categories: Drupal

jordanpagewhite: Drupal 8, hook_form_alter()

17 January 2016 - 4:00pm

I am developing a Drupal 8 site right to manage scholarships and scholarship applications at the university. I wanted to add a bunch of custom fields to User and group them with the field_group module, but field_group generated an error that caused White Screen of Death (WSOD) up on adding a field group. I reported the error to the module maintainer, but he seemed to denounce the possibility that it generated an error in his response to me.

Categories: Drupal

ThinkShout: RedHen Raiser in Action

17 January 2016 - 4:00pm

This past summer, Sean shed some light on one of our most exciting Drupal contributions to date: RedHen Raiser, our open source peer-to-peer fundraising solution, the first of its kind to be built entirely with Drupal. Thanks to the Capital Area Food Bank of Washington, D.C., we finally had the opportunity to build a platform that would provide fundraisers a highly-customizable, Drupal alternative to SAAS applications like Causevox and Crowdrise.

After a year of leveraging Raiser as their vehicle for crowdfunding, we’re thrilled to see that the Capital Area Food Bank of Washington, D.C. brought in over $324,000, representing tens of thousands of pounds of food, through 17 different campaigns to help fight hunger in their community.

The Food Bank recently shared an infographic with its constituents that breaks down the donations they received through their RedHen Raiser campaigns over this past year.

It’s really exciting for us to think of what other organizations will accomplish with RedHen Raiser. Raiser’s features allow fundraisers to tailor their campaigns to fit a variety of causes. The Food Bank utilized the Teams feature to give local law firms their own fundraising pages during the “Food from the Bar” campaign. There are so many other possible applications: walk-a-thons, food drives, even parties - as the Food Bank has shown us - have the potential to be great fundraising opportunities for your organization, and they can all be easily managed with RedHen Raiser.

We can’t thank the Food Bank enough for working with us to release RedHen Raiser as an open source platform so other members of the Drupal nonprofit community can benefit from it, too – and, of course, make it even better.

Is your organization using RedHen Raiser to crowdfundraise? Get in touch with us. We’d love to hear about your experience and share your story.

Categories: Drupal

ARREA-Systems: Create list view in custom module (part 1)

16 January 2016 - 4:58pm
Create list view in custom module (part 1) JK Sun, 01/17/2016 - 08:58

In our EK management tools suite we have custom designed lists of items like for instance list of management documents.

Those lists are build with custom codes and templates which is somehow more convenient to manage with complex data, links, menus and filters as in the example below.


However for simple list, the views module is very useful and can be integrated in a custom module as well to automatically create the list.

Here is an example with companies list in the system address book module showing the company name as link and a filed about the type of record plus a simple filter box.

Categories: Drupal Drupal, Hippies and Backend Restrictions

16 January 2016 - 2:00pm

You might have heard of Burning Man. Basically it's a lot of hippies settling down in the desert for a few days, setting up small camps with diffrent themes that make up a big, temporary city.

It's not for me.

Radical Self-expression is one of Midburn ten principles. © Eyal Levkovich.

Continue reading…

Categories: Drupal

Drupal Bits at Web-Dev: Moving Views Exposed Filters Form Elements Around

15 January 2016 - 1:51pm

In Drupal 7, Views allows you to easily create exposed filters and alter a lot of the logic involved.  However, sometimes you get requests to add text to the form or position things in ways that the Views UI does not allow for.

I've got two solutions that are arguably not as Drupal-like as I would like, but I've run into some dead ends on occasion with trying to fullfill requests with only Drupal-like alterations.  And of course if there are better ways to do it, I am open to them.

The first method gives you primary control over the exposed form by using hook_form_FORM_ID_alter().  You would think it would be easy to alter the order of form elements in that hook, but it is a little complicated because of the way the form elements can have #weight but that the #info array has the final say over order.

To get around this and make it easy to juggle things around and add items to a form, I created a Drupal Views FormManipulator class.

If you need to do even more advanced juggling of form, header, footer and other views elements I have also resorted to using QueryPath & hook_views_post_render().  It gives you a lot more control, perhaps a bit more fragile if you are not careful to use stable selectors, but it does let you move things that would require lots of  different hooks, custom templates AND still leaving you with not quite 100% of what the client is asking for. 


Categories: Drupal

about seo