Blog Archives

Adding Entity Wrapper Class from Field Value using Display Suite

NOTICE: This works fine in Drupal 7. For Drupal 8 please see https://www.drupal.org/node/2863420 Sometimes as a developer you need to provide your Drupal authors with the ability to choose different variations of a particular content object. For example, imagine you have a Callout paragraph bundle

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

Pointing All Taxonomy Term Links to ApacheSolr Search Results

I’ve been working on a project that leverages ApacheSolr for many of the displays on the site. One of the requirements is that every instance of a taxonomy term link on the site needs to point to search results pre-filtered

Tagged with: , , ,
Posted in Development

Indexing Specific Field Collection Fields in Apache Solr for Drupal 7

I’m not sure how much of this is possible without Display Suite, but here’s the setup I’ve used to index specific fields within a field collection as part of the parent entity. I use the “Search index” view mode to

Tagged with: , ,
Posted in Development

Quickly Implement a Block as a Paragraph in Drupal 7

Disclaimer: As with most tasks in Drupal, there are several ways to do this. My goal here was to see how quickly it could be done without writing code and without introducing unnecessary complexity. Goal — quickly implement a newsletter

Tagged with: , , , , ,
Posted in Development

Bulk Add URL Redirects in Drupal 7

Here’s a quick example showing how to add URL redirects (for the redirect module) in bulk. Instead of a separate page for each list of “fellows”, we built a single view with exposed filters to choose a semester. The original

Tagged with: ,
Posted in Development