Valuebound: Drupal 8: How to create a custom block programatically

Planet Drupal - Mon, 2016/12/19 - 8:33am
Drupal 8: How to create a custom block programatically Jaywant.Topno Mon, 12/19/2016 - 02:33

Valuebound: Drupal 8: Custom Block Creation programmatically

Planet Drupal - Mon, 2016/12/19 - 8:33am
Drupal 8: Custom Block Creation programmatically Jaywant.Topno Mon, 12/19/2016 - 02:33

OSTraining: How to Get the Link to a Tab in Drupal

Planet Drupal - Fri, 2016/02/12 - 10:02pm

One of our members asked for a way to get the direct link to a tab while using Quick Tabs for Drupal.

He want to use a URL to open the page with the desired tab enabled.

In this short tutorial, I'll tell you how to do it. Let's start...


Chromatic: Backup Your Drupal 8 Database to S3 with Drush & Jenkins

Planet Drupal - Fri, 2016/02/12 - 7:26pm

There are many different ways to handle offsite database backups for your Drupal sites. From host provider automations to contrib modules like Backup and Migrate and everywhere in between. This week, I was looking to automate this process on a Drupal 8 site. Since Backup and Migrate is being rewritten from the ground up for Drupal 8, I decided to whip up a custom shell script using Drush.

I knew I wanted my backups to not only be automated, but to be uploaded somewhere offsite. Since we already had access to an S3 account, I decided to use that as my offsite location. After doing a bit of Googling, I discovered s3cmd, a rather nifty command line tool for interacting with Amazon S3. From their

S3cmd (s3cmd) is a free command line tool and client for uploading, retrieving and managing data in Amazon S3 and other cloud storage service providers that use the S3 protocol, such as Google Cloud Storage or DreamHost DreamObjects. It is best suited for power users who are familiar with command line programs. It is also ideal for batch scripts and automated backup to S3, triggered from cron, etc.

It works like a charm and basically does all of the heavy lifting needed to interact with S3 files. After installing and setting it up on my Drupal 8 project's server, I was able to easily upload a file like so: s3cmd put someDatabase.sql.gz s3://myBucket/someDatabase.sql.gz.

With that bit sorted, it was really just a matter of tying it together with Drush's sql-dump command. Here's the script I ended up with:

# Switch to the docroot. cd /var/www/yourProject/docroot/ # Backup the database. drush sql-dump --gzip --result-file=/home/yourJenkinsUser/db-backups/yourProject-`date +%F-%T`.sql.gz # Switch to the backups directory. cd /home/yourJenkinsUser/db-backups/ # Store the recently created db's filename as a variable. database=$(ls -t | head -n1) # Upload to Amazon S3, using s3cmd ( s3cmd put $database s3://yourBucketName/$database # Delete databases older than 10 days. find /home/yourJenkinsUser/db-backups/ -mtime +10 -type f -delete

With the script working, I created a simple Jenkins job to run it nightly, (with Slack notifications of course) and voilà: automated offsite database backups with Jenkins and Drush!


Another Drop in the Drupal Sea: Drupal Chat: Choosing Contributed Modules

Planet Drupal - Fri, 2016/02/12 - 6:38pm

One of the great things about Drupal is its extensive contributed module base. It's almost always the case that "there's a module for that." The trick is deciding which module to use. Even though Drupal emphasizes collaboration, one will still frequently find that there is more than one way to solve a particular problem by using contrib.

read more

Categories: What version of PHP does Drupal 6 need?

Planet Drupal - Fri, 2016/02/12 - 3:36pm

The short answer is: Drupal 6 officially supports only PHP 5.2, but you should use the highest version of PHP that doesn't break your site!

For the longer answer:

PHP 5.2.17 is the latest version of PHP in the 5.2.x branch of the popular programming language. While there are several newer versions, it's a safe bet that legacy code will operate under 5.2.17. However, there are potential security holes with earlier versions of PHP.

Drupal 6 core should safely work on PHP 5.3, 5.4 and 5.5 but you may have difficulties with modules that have not been kept active. This is especially true of legacy Drupal 6 custom modules. The right thing to do is to start with PHP 5.5 and work backwards until you hit a version that works with your needed modules. Rarely should ever need to go as far back to PHP 5.2.

In general, newer versions offer better security.

The 5.2.x branch was "end of lifed" on the 6th of January, 2011. That's more than 5 years ago at this writing. Even though efforts on PHP 5.3.x and PHP 5.4.x are also discontinued, development didn't halt until August 2014 and September 2015 respectively. There have been Drupal security vulnerabilities that only exist when running Drupal on older versions of PHP. With Drupal 6 nearing "EOL", there's no need to stack the deck against yourself if you are trying to attempt modernizing.

Also, we recommend using Pressflow - a fork of Drupal 6 core, that has improved performance and better support for newer PHP versions.

Some brief notes on your PHP configuration:


Drupal core announcements: Reminder: Drupal 6, 7, and 8 core security release window moved to February 24

Planet Drupal - Fri, 2016/02/12 - 2:28pm

This is an early reminder that this month's security release window for Drupal core, which would normally be on the third Wednesday of the month, is being moved to February 24 to avoid conflicting with DrupalCon Asia.

February 24 is also the end-of-life date for Drupal 6, so this will be the last security release window for Drupal 6.

Categories: Drupal 8 Views Plugins (Part 2) : The display extender plugin

Planet Drupal - Fri, 2016/02/12 - 11:06am
Let's see how and why to use a views display extender plugin.

Lullabot: Drupal 8 Contrib Module Development with Dave Reid, Juampy NR, & Andrew Berry

Planet Drupal - Thu, 2016/02/11 - 10:00pm
Matt & Mike discuss Drupal 8 module development with Dave Reid, Juampy NR, and Andrew Berry onsite at the Lullabot retreat in Palm Springs, CA.

Drupal core announcements: 8.1.0 will be released April 20; beta begins March 2

Planet Drupal - Thu, 2016/02/11 - 9:58pm

Drupal 8.1.0, the next planned minor release of Drupal 8, is scheduled for Wednesday, April 20, 2016. Minor releases include new features, usability improvements, and backwards-compatible API improvements. Here's what this means for core patches.

Drupal 8.1.0-beta1 will be released March 2
  • In preparation for the minor release, Drupal 8.1.x will enter a beta phase on March 2.
  • Developers and site owners can begin testing the beta.
  • The 8.2.x branch of core will be created, and future feature and API additions will be targeted against that branch instead of 8.1.x.
  • All outstanding issues filed against 8.1.x will be automatically migrated to 8.2.x once it is opened.
  • During the beta phase, core issues will be committed according to the following policy:
    1. Issues that are allowed for patch releases will be committed to all three minor branches (8.0.x, 8.1.x, and 8.2.x).
    2. Issues specific to added 8.1.x functionality, or disruptive changes that have a positive impact outweighing their disruption, will be committed to both 8.1.x and 8.2.x. (Such issues can be moved back to the 8.1.x branch after the automatic migration.)
    3. Most issues that are only allowed in minor releases will be committed to 8.2.x only.
Drupal 8.1.0-rc1 will be released April 6
  • The release candidate phase for the minor release begins on April 6, and starting on that date, the 8.1.x branch will be subject to release candidate restrictions, with only critical fixes and certain other limited changes allowed.
  • April 6 is also the final scheduled patch release window for 8.0.x, and it will not receive further development or support after that date aside from its final security release window on April 20.
  • All outstanding issues filed against 8.0.x will be automatically migrated to 8.1.x after the final 8.0.x patch release. Future bug reports should be targeted against the 8.1.x branch.
  • Minor versions may include changes to user interfaces, translatable strings, themes, internal APIs like render arrays and controllers, etc. (See the Drupal 8 backwards compatibility and internal API policy for details.) Developers and site owners should test the release candidate to prepare for these changes.
  • 8.2.x will remain open for new development during the 8.1.x release candidate phase.

See the Drupal core release cycle overview, Allowed changes during the Drupal 8 release cycle, and Drupal 8 backwards compatibility and internal API policy for more information.

As a reminder, we have until the start of the beta to add great new features to Drupal 8.1.x, and migrate, usability, and bugfixes are all priorities for 8.1.0.


HollyIT: Windows+Vagrant+WinNFSD Without File Update Problems

Planet Drupal - Thu, 2016/02/11 - 7:07pm
Categories: DrupalPlanet Drupal

I have used Windows to develop on for years. I have been through WAMP, XAMPP and EasyPHP, plus also going my own route to handle my web development. Last year I switched to Vagrant so that I could mimic the varying servers I work with from all my clients. Of course I was quickly plagued with the problem most Windows vagrant users face - extremely slow page loads.


Darren Mothersele: Build Your Own PHP Framework

Planet Drupal - Thu, 2016/02/11 - 6:00pm

I'm excited to announce that I'll be back running training at this year's Drupal Camp in London. This will be the 3rd year in a row that I've offered training at the camp. I'm doing something a bit different this time...

Build Your Own PHP Framework

In this training you will build your own PHP framework.

But, why reinvent the wheel?

Building your own framework is a great way to learn the fundamentals of modern PHP. Regardless of your choice of framework, this will make you a better developer. A similar foundation of components underlies Drupal, Symfony, Silex, and Lavavel.

If you are a developer going from Drupal 7 to Drupal 8 then you need to adopt an object-oriented mindset.

Drupal doesn't always get it right. If you understand the basic principles you know when and why you're breaking them. You can make pragmatic choices as a programmer, without embodying bad practices.

"Build Your Own Framework" is a fun training to learn modern PHP. You will learn the "SOLID" principles of PHP package design. The training will demystify dependency injection, hexagonal architecture and other design patterns. We will look at HTTP Foundation and the other Symfony components.

Come armed with a basic knowledge of PHP, a laptop that can run PHP, and an open mind. Leave with a better understanding of the principles behind modern PHP and Drupal 8.

Tickets available here.

The training will be held on Friday March 4, 2016 at City University London.


IXIS: Building websites for the blind

Planet Drupal - Thu, 2016/02/11 - 5:15pm

This months Northwest Drupal User Group (NWDUG) in Manchester had a lovely visit from a non developer to talk about how the Internet has changed his life and the challenges of using the Internet as a blind person.

Being blind since he was a child has meant that some activities weren't possible before the Internet became accessible to everyday people - such as reading the news or magazine articles. Now Sunil works with the Internet everyday at his job in the British Red Cross.

read more


Drupal Association News: Global Training Days - February 2016 Summary

Planet Drupal - Thu, 2016/02/11 - 4:05pm

We kicked off the 2016 Global Training Days on February 5th. Twenty-two sites held a training in 11 countries, making it a great start to all things training in 2016.

Training events were held all over the globe in a variety of spaces. From offices to the public library and spaces where public university and governmental institutions collaborated with private organizations, Drupal was brought to a wide audience. Trainers gave introductory lessons with demos and hands-on site building exercises to attendees. Thank you to everyone who participated!

Here are just a few of the tweets we received about the first of the 2016 Global Training Days.

#DrupalGTD #Drupal training in progress at @valuebound in association with @drupalbangalore @BangaloreDrupal

— Neeraj Kumar (@neerajskydiver) February 6, 2016

Awesome #DrupalGTD in #Lviv! Thanks everyone! #learndrupal with @lemberg_co_uk

— Lemberg Solutions (@lemberg_co_uk) February 8, 2016

And in the end...thank you for this beautiful #DrupalGTD !!!!@bonsaimeme @SparkFabrik @SapienzaRoma #Drupal

— Bmeme (@bonsaimeme) February 5, 2016

All smiles at our #Drupal Training Day @SunSoftCity w/ @consultndesign. #DrupalGTD

— Drupal Hub (@thedrupalhub) February 5, 2016

See more photos and updates at #DrupalGTD on Twitter. The full list of participants is on the 2016 page.

Learn more about the program at or sign up to provide training at the next event.

Personal blog tags: Drupal Global Training DayGTD
Categories: Manage meeting room availability and take bookings with BAT for Drupal

Planet Drupal - Thu, 2016/02/11 - 3:45pm
We put together extensive documentation on how to use BAT, using a meeting room availability and booking example throughout. This is one of the most often requested features - especially from libraries and educational institutions - so we hope you will find it useful. We hope this will help and would love to hear your thoughts - get in touch.

Pronovix: Publishing a code sample book from Stackoverflow to LeanPub using Drupal and GitLab

Planet Drupal - Thu, 2016/02/11 - 3:09pm

In this blogpost we want to share how Bruno Lowagie (the original developer of iText) designed a workflow that allows him to publish questions and answers from Stackoverflow on the iText Drupal site and then export them to LeanPub (utilizing a custom Drupal module).


drunken monkey: Create Git diffs with proper function context

Planet Drupal - Thu, 2016/02/11 - 1:37pm

For years I have been annoyed (slightly, but still) that Git diffs for PHP classes always just contained the class header instead of the method header as the function context. I finally got round to doing a bit of research and it turns out that the solution is astonishingly easy: just one small and simple config file and it will magically work.

The problem

You might have noticed it, and maybe been annoyed by it, too: when you create a diff file with Git and have changes inside PHP class files, you get hunks that look like the following:

@@ -40,6 +40,7 @@ class SearchApiViewsHandlerFilter extends views_handler_filter {
       '<=' => t('Is less than or equal to'),
       '=' => t('Is equal to'),
       '<>' => t('Is not equal to'),
+      '!=' => t('Is REALLY not equal to'),
       '>=' => t('Is greater than or equal to'),
       '>' => t('Is greater than'),
       'empty' => t('Is empty'),

So, where you would normally expect the function context, to quickly get an idea what that change means, the diff instead just contains the class name, which is much less helpful (especially if the file name already tells you the class).

Well, after years of being regularly (slightly) annoyed by this (more so in recent years, with the OOP shift in Drupal 8), I finally searched this new place called "the interwebs" and arrived at the very simple solution.

The solution

It turns out Git's diff functionality already has support for creating the right function context information for various file types – it just doesn't know which files correspond to which file type. (It seems not even the standard .php extension is recognized by default.)

To remedy this, simply create a file with the following contents:

*.engine   diff=php
*.inc      diff=php
*.install  diff=php
*.module   diff=php
*.php      diff=php
*.profile  diff=php
*.test     diff=php
*.theme    diff=php

Save the file either in .git/info/attributes or .gitattributes (for just the local project), or (to change this globally) in $HOME/.config/git/attributes (or $XDG_CONFIG_HOME/git/attributes, if that variable is set). That's it – testing again, we now see the proper function context in the diff:

@@ -40,6 +40,7 @@ public function operator_options() {
       '<=' => t('Is less than or equal to'),
       '=' => t('Is equal to'),
       '<>' => t('Is not equal to'),
+      '!=' => t('Is REALLY not equal to'),
       '>=' => t('Is greater than or equal to'),
       '>' => t('Is greater than'),
       'empty' => t('Is empty'),

Much better, right?

Note: I haven't yet found out where to put the global attributes file for Windows. If you know, please post a comment and tell me, and I'll include it here.

Background information

For more information on Git attributes, please see the documentation. I didn't know about this at all before, but it seems there's actually a lot you can configure per file type, so there might be other very practical tips for customization.
If you find or know of any, please post them so others can profit from them, too – just as I hope this post was useful to at least a few of you!

As an afterthought, I've also added this tip to the Git documentation in's handbook. Hopefully, more people will find it that way.


Wellnet Blog: Logging in Drupal 8

Planet Drupal - Thu, 2016/02/11 - 11:48am

Many Drupal websites are not just simple websites but real applications, with many functionalities, integrations and logic. It’s often necessary to keep track of what is happening in the application to understand if something went wrong or even just to monitor the user activities.
It is...


DrupalCon News: User Experience Design with Drupal and Beyond

Planet Drupal - Thu, 2016/02/11 - 5:04am

Did you know you, yes YOU, could potentially provide the most valuable information at all of DrupalCon New Orleans?


Acquia Developer Center Blog: What We're Up To at DrupalCon Asia in Mumbai

Planet Drupal - Wed, 2016/02/10 - 9:07pm
Jeffrey A. "jam" McGuire

Acquia is once again a sponsor of DrupalCon, and those of us who have the chance to take part in DrupalCon Asia in Mumbai, India are getting excited. This post covers the sessions we'll be part of in Mumbai.

Tags: acquia drupal planetdrupalconMumbai