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 specify which fields I want to index on each content type. Here’s what that looks like:


As you can see, the “Versions” field and the “Associated people / organizations” field are field collections. In this example I only wanted to index a couple of fields from the “Versions” field collection as part of the search index for each “Book” node. Read more ›

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 listing (using Views) that can be dropped into any paragraph field and can have a unique title per use.

The output would be a simple block from Views. We already use Display Suite, so naturally we use a DS-centric approach. Read more ›

Tagged with: , , , , ,
Posted in Development

Sort “Select an existing field” options in Drupal by Label instead of Type

Normally Drupal sorts the “Select an existing field” select list by the field types. Here’s an example of what this looks like:


This looks good at first glance, but often it’s hard to quickly find the field you want to reuse. Most of the time you’re scanning the list for the name (label) of the field you want to reuse. Wouldn’t it make more sense to put the field label at the beginning and sort by that? I thought it would, so I made it happen with a quick userscript.

Read more ›

Tagged with: , ,
Posted in Development

Paramiko error: Use module Crypto.Signature.pkcs1_15 instead

Recently I started getting the following error in a script that never had any problems in the past:

There wasn’t much information related to this error in regards to Paramiko.

Eventually I was able to “fix” it by running:

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 paths looked like “/fall-2000-fellows” and the new path looks like “/fellows/list?semester=5493”.


Tagged with: ,
Posted in Development

Random Mouse Distance in Keyboard Maestro

Here’s one way to choose a random item in a select list using just mouse movements and a random number. If you’re trying to do this in a browser there are cleaner ways to do it (javascript, chrome/safari actions, etc.), but for general usage across many applications this is a pretty universal solution.


I was surprised to find that you can type variables into the tiny coordinate text fields. They get bigger when you do.

When executed, this will select a random item (excluding “- None -“) from the select list.

Tagged with: ,
Posted in Tech Tips

Adding a “Filter by year” Facet for a Date Field in Apachesolr for Drupal 7

A Drupal 7 site I’m working on makes use of the Apache Solr Search module and FacetAPI. Some of the content has a date field named field_s_date. I was tasked with providing a sidebar “Filter by year” facet block to filter the content by the year value of this date field. I’m pretty sure I could have done this a few different ways, but I settled on adding the year value as a separate field to the solr index and adding an associated facet using hook_facetapi_facet_info() .

First, to add the field, I used hook_apachesolr_index_document_build() in a custom module as follows: Read more ›

Tagged with: , , ,
Posted in Development

Rendering an Image in Apache SOLR Search results (Drupal 7)


There are a few ways to get extra information into the output of your Apache Solr Search results. The most efficient ways involve getting the information into the solr index and pulling it directly from the solr index. We do not want to introduce extra node_load()  calls to render our search results. We do not want to have to use Views either.

So, using just apachesolr and some functions, I’m going to show how to get an image field into the search index and pull it back out in our result output. I know I’m not handling alt and title attributes in this example. I’ll let you figure that one out.

This is a step-by-step breakdown of my experience getting this to work. In this example I’m attempting to render an image field called field_forum_image for the forum (content type) nodes in my search results. You can use the same procedure for adding other fields, but please make sure you understand the solr prefixes (e.g., ss, ts, tm, etc.) before doing so. You can find these in the schema.xml file with in the apachesolr module. Read more ›

Tagged with: , ,
Posted in Development

Use Keyboard Maestro to Hide Instead of Close an Application

I use SnagIt to capture screenshots. The editor window that appears after you capture takes a few seconds to open if the application isn’t running. I realized that, while the capture tools remain open, the editor goes away when I hit ⌘W to close the window. Instead of using ⌘W to close the editor window, I sometimes remember to use ⌘H to hide the window, which hides the window but leaves the application open. The editor window pops open much quicker if the application is still open.

Using Keyboard Maestro I’m able to intercept the ⌘W that I do all the time (muscle memory), and turn that into a ⌘H. Read more ›

Tagged with: ,
Posted in Tech Tips