Blog Archives

Migrating a Drupal 7 User Profile2 Image Field to a Drupal 8 User Image Field

Consider this scenario: Drupal 7 site contains Profile2 profile called person with image field called field_oldsite_person_image. Users each have a profile2 profile associated with their account. Drupal 8 site has an image field called field_newsite_user_photo on the user entity itself. If you need to

Tagged with: , , , ,
Posted in Development

Quick Tips for a Drupal 7 to Drupal 8 Migration

Here are a few quick tips for a Drupal 7 to Drupal 8 migration. I will add more over time; admittedly it’s pretty lame right now! For general Drupal 8 Migrate API tips, you may also want to check out

Tagged with: , , ,
Posted in Development

Only Migrating Published Nodes in a D7 to D8 Migration

I’m not going into much detail here but hopefully this helps someone. If you need to migrate only published nodes you can extend the d7_node plugin and add a condition to the query. First, create a file in your module like /modules/custom/mysite_migrate/src/Plugin/migrate/source/MysiteNewsNode.php

Tagged with: , , ,
Posted in Tech Tips

Basic HTTP Authentication in Drupal Site Using settings.php

Here’s a quick and painless way of preventing public access to a Drupal site using settings.php (or settings.local.php). I’ve been using this for development and staging sites that I want to keep private. If you want this to be available

Tagged with: , , ,
Posted in Development

Adding Entity Wrapper Class from Field Value using Display Suite

NOTICE: This works fine in Drupal 7. For Drupal 8 please note: https://www.drupal.org/node/2863420 This may not work with paragraph bundles (because you don’t have a Token view mode). Maybe there’s a way, but I don’t have time to mess with it. Sometimes

Tagged with: , , , ,
Posted in Tech Tips

Friendly URL for Views Contextual Filter on a Boolean Field

I have a story content type that has a corresponding Views listing page. The stories can be flagged as Featured through a checkbox/boolean field ( field_story_featured ). The stories also have a Story Type value ( field_story_type ). The views listing page needs to have the

Tagged with: , ,
Posted in Development

Backing up a File Before Overwriting It (in Drupal 7)

I’m communicating with a 3rd party SOAP API to pull some data into a CSV file. The CSV file will be used by Feeds and/or Migrate so it’s important to have the file named exactly the same for each run. I

Tagged with:
Posted in Tech Tips

Adding an Inline Style Attribute to an Entity in Drupal 7

The point of this post is to illustrate adding inline styles without creating template files. Normally we add classes via $vars['classes_array']  but sometimes inline styles are required. This code isn’t too useful as written (make all text red for all

Tagged with:
Posted in Development

Entity Reference Referrer – Getting Entity Reference’s Parent/Referrer Entity ID and Type

Out-of-the-box, the Entity Reference module doesn’t provide a way to access the referrer entity’s fields from within the referenced entity. I have two ways of doing this. The first is to patch the entityreference module (not ideal unless this patch

Tagged with: , ,
Posted in Development

Appending Language to Menu Items in Menu Admin (Drupal 7)

If you are working with a Drupal 7 menu that contains menu items across multiple languages it is a little cumbersome to see them all on the same screen. Right now we have all of the translations in place (3

Tagged with: , ,
Posted in Development