Drupal Custom Contextual Filter

A custom contextual filter for Views in Drupal 8 is demonstrated using the Data project. Only a small amount of code is needed for the custom filter.

Set up Drupal

Begin by setting up Drupal and installing the Schema and Data projects.

composer create-project drupal-composer/drupal-project:8.x-dev contextual --no-interaction

Create a database and visit the website to install it. Now install a couple of contributed projects.

Decoupled Drupal, GraphQL and React

Decoupled Drupal is gaining increased interest.  Decoupling refers to using Javascript for the front end of the website and Drupal for the back end content.  Many of the tutorials leave out critical information and even quite recent tutorials are already out of date because the software is changing so quickly.  Developing a production website under these conditions is still risky but has intriguing possibilities.  Javascript avoids page reloads and promises increased speed and separation of the display from the data.  But building a display yourself loses things like search engine optimizat

Migration in Drupal - Part 2

Part 1 looked at how to put the source database credentials in settings.php.  Part 2 looks at how to specify the source website root so that files are properly transferred.  After the fix for the database settings in part 1 the command for configuring the migration is

drush migrate-upgrade --legacy-root=http://mydrupal7site.com --configure-only

The import of the files is done by running

PHP stack trace

Tracking down an error in PHP code often requires knowledge about how the function is being called.  In cases such as this a stack trace is often useful to show the call stack.  PHP has a function debug_backtrace() that I have found useful in displaying the call stack.  But it seems to use a lot of resources.  So I wanted to quantify this and try a new approach that I have been using lately.  I used something in Drupal 8 that I was debugging.  Results will differ greatly depending on the case but the overall trends should be similar.  I used

Xdebug with Vim for Docker for Mac with Ubuntu 16.04

Integrated Development Environments (IDEs) are nice for debugging problems but with Docker containers they have to be set up to work remotely. Vim may not be as nice an interface but has an advantage of being able to run in the container making it easier to get set up and running quickly. This is especially true for new releases where there is not much information yet on configuration.