aaron's blog

How do you define a facet in Drupal? (As in faceted search)

There's two kinds of searches in Drupal.

The first is a keyword search, it's what you're used to with say, Google. Type a word or phrase and you see results that are related to that phrase.

The other search is called faceted search, which is what you might see if using the Best Buy website. You may select attributes about the thing you are searching for to refine your result set. For example, to say I'm looking for: an computer manufactured by Apple, with a screen size of 15", priced less than $3000, which is on sale--here your are doing a faceted search.

SASS mixin for variable font sizing between a minimum and maximum using media queries and the vw unit.

Ever want to declare a title to grow from 28px to 60px based on browser width, but always be at least 28px and never more than 60px? This SASS mixin does the heavy lifting in terms of math and media queries to figure the necessary CSS to do just that.

How to add cache-busting to itok image derivative urls in Drupal 7 for entity image fields

This will work to fool varnish caching of images. I wrote this because certain admins were not able to see their image derivatives immediately upon node save due to Varnish caching of the image urls. Installing the Varnish module was not possible due to hosting situation. This solution fixed the issue.

Remove the tabledrag from a field in Drupal using your theme

Tested in Drupal 8, probably works in Drupal 7 as well. Add the following to your theme's .theme file or template.php, based on drupal version.

Function to test for visible output in a render array

Here is a function to add to a Drupal theme that will return if a renderable array contains content. You can use this with an if statement to only include wrapper markup on content that actualy renders.

BASH find not finding all files

A painful discovery in the sense of time... the missing quotes on the following code was causing unexpected behavior when I was trying to locate files in BASH using find. When I did not have the double quotes around the -name option values, they were not functioning as wildcards as I'd expected.

This did not work:

files=$(find "," -name *.psp.md -or -name *.psp.txt -or -name *.psp.sh)

This did work:

files=$(find "." -name "*.psp.md" -or -name "*.psp.txt" -or -name "*.psp.sh") 

Code Snippet: How to use a field to control node access

Drupal 7 node access per entity using a field dropdown, callback functions and the node access API.
Valid XHTML 1.0 Transitional