Node content type object in Drupal 8

When obtaining the node types on a given Drupal site in Drupal 7 we use:

$types = node_get_types();

And the content type machine name is available from:

$names = array();
foreach ($types as $type) {
  $names[] = $type->type;
}

In Drupal 8 we use the following:

use Drupal\node\Entity\NodeType;

$types = NodeType::loadMultiple();
$names = array();
foreach ($types as $type) {
  $names[] = $type->id();
}

Kent Shelley Mon, 07/11/2016 - 20:45
Installing Varnish 4.x on Apache Debian 8 server (Jessie) with Drupal 8

Varnish is a very fast caching mechanism for web applications but it is not always easy to install.  In the latest version there are a number of changes pertinent to Debian servers.

The following assumes you are working as root.  If not, then you need to add sudo to the front of all commands.

Installing Varnish on the server

At the command line:

Kent Shelley Sat, 07/02/2016 - 03:04
Create a Formatter Plugin to provide active trail links in Drupal 8 Views list

In this example I show how to create a formatter plugin to provide an active trail class to highlight the link of the current page in a Views list.  This behaviour is native to Drupal menus and I could have created a menu but that would not be dynamic and anyway, I wanted to see what is involved in applying active trail classes to a Views list.

Kent Shelley Tue, 06/28/2016 - 08:17

Using Colorbox Inline with Views to Display image AND content in a Colorbox

For this implementation you will need to install Colorbox and Colorbox Inline module on a Drupal 8.1 site or higher.  For this exercise I wanted to create the portfolio page on this site, so that when I click on an image on the page I get a lightbox with the image, title (with link) and description of the item.  First create a block View with the image and the desired fields.  If you are displaying more than one image, as I am, using masonry, then you will need to get the ID field (hidden) to use as an identifier.  I have also obtained the image field twice.

Chorus Corporate

A site in the Chorus family of companies whose purpose is to provide information to the public about the company finances, directorship and other aspects related to corporate management.  This site is chiefly information only and does not provide any dynamic elements.  The video banners involved contributing back a Video JS module

Chorus Consumer

An Enterprise level website for a major NZ Company with about 4000 unique visitors per day.  This website was developed as a team with technical lead from Passing Phase Web Development.  The site consists of a number of information pages, some online tools and various forms enabling the public to respond to matters involving the services available through the company.  The tools are made using third party code while the forms use Drupal contact form and webform module.