• Development

    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 entity types, really?), but drop in a conditional to affect specific entity types and replace the styles with something useful like setting a background image URL from a field within the entity and you have a handy snippet.

     

  • 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 went out to the community via proper channels; perhaps I should get on that?). The second is to mimic entityreference’s “Rendered entity” field formatter but modify it to include the referrer information. I recommend the second method for now.

  • Development,  Tech Tips

    Triggers in iTerm – Watching For Specific Strings

    I was recently performing a git-add in patch mode (  git add -p ) as I normally do, and realized there were a few lines I needed to make sure I didn’t commit. These lines were sandwiched between other lines that I did want to commit, and there were hundreds of changes, so it was hard to spot them. I wondered if iTerm2 had a way of highlighting or alerting when a specific word shows up in the terminal. To my surprise I found a “Triggers” section under the “Profiles » Advanced” tab in the settings for the app. iTerm2 really can do everything!

  • Tech Tips

    Microphone Enable/Disable with Alert – Keyboard Maestro Macro

    In the past I’ve used Shush to achieve a push-to-talk or push-to-silence setup on my Mac. It works alright but more often than not I forget which mode I’m in, or whether I’m silenced or not. This leads to awkward moments in meetings.

    I’ve solved the problem using Keyboard Maestro. This macro, triggered via CTRL-m simple enables or disables the current “input” device (whatever is selected in the Sound preferences) by setting its level to 0 or 100. It’s a toggling macro so you can use the same hotkey to flip between the two states. Most importantly, though, is the nice popup alert that appears when you go into “disabled” mic mode. This window is hide-able if it gets in the way, and it also disappears if you re-enable (via hotkey OR the RE-ENABLE button). You can safely disable the “Custom HTML Prompt” action if you don’t want to see the prompt. Here’s what the popup looks like:

    MicDisable

  • 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 nodes per piece of content), but we haven’t translated the titles yet. It’s very hard to see which items will appear for which languages. Imagine if we add 75 more menu items!

    2016-08-31_15-01-44

  • 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 (using FacetAPI) on the term. The other requirement is that if a taxonomy term’s vocabulary doesn’t have an associated search facet, the user should end up on the search page with results as if the user had searched for the term’s name in the search text box.

    1. If you see a “Climate Change” term (tid = 153) link from the “Topics” vocabulary (vid = 8), it should render as  <a href="/search/site?f[0]=im_field_tr_topics%3A153">Climate Change</a> in the DOM.
    2. If you see a “Blog” term (tid = 123) link from the “Keywords” vocabulary (vid = 6), it should render as  <a href="/search/site/blog">Blog</a> in the DOM.
  • 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 specify which fields I want to index on each content type. Here’s what that looks like:

    2016-07-21_08-14-15

    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.

  • 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.

  • 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:

    2016-04-22_11-40-52

    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.

  • 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: