Drupal

Drush: Setting up and Leveraging Site Aliases

If you haven't yet set up site aliases for Drush, what are you waiting for?!?--Life is so much easier once your localhost can start communicating with your remote: bring site files and databases straight from production to local without logging into your CPanel or PHPMyAdmin; clear site cache on Production without logging into the site and navigating the admin UI. It can be tricky to set up, but once you have, you'll wonder how you ever developed without site aliases.

Background: Why Site Aliases Rock

My main client is hosted on Acquia; despite the tendency to be both pedantic and overly optimistic in regards to all things Drupal, Acquia, as a company, can be extremely considerate to the developers on its platform. One of the perks of being with Acquia is having out-of-the-box support for Drush Site Aliases.

PHPMyAdmin: Useful Strategies for Managing Drupal

I don't always crack open my Drupal database... but, when I do: it always leaves me a happier person. If you're like me, perhaps you often overlook the power of your Drupal site's database. It's effectively a warehouse, and Drupal is a warehouse manager: retrieving all the items your site-visitors request and updating what sits on your warehouse shelves--all 'on the fly'. Still, there are limits to Drupal's ability. It may be good at coordinating between end-users and the proverbial warehouse, but it's not really an inventory manager. To get a really good feel for what's going on in you Drupal database, you'll need a different tool: PHPMyAdmin. Here are some simple ways I like to leverage this tool in my Drupal development workflow.

Clearing Drupal's Site Cache

I've covered this before in a post on how database cache can kill your Drupal site. It's worth mentioning again: if you don't have Drush and you're without access to Drupal, you can clear your site's cache in PHPMyAdmin by simply dropping any of the tables appended with 'cache_'. From the "Structure" tab of your database, filter for 'cache_' and drop everything that comes up:

Flexbox: Styling Top Row Items in Scalable Columns

Touching again on the complexity of making flex-box columns scalable; this time I focus on one of the design challenges with this layout. When child items are burdened with the limits of CSS, sometimes the solution is to think outside of the box, literally, and work with the parent instead.

Background: the Design

I love Flexbox--it's a fundamental in responsive design. As empowering a device as it is, though, it's not without it's limits. It just so happens that I work with a designer who has a real knack for exposing these limits. The minute I think I've got flexbox under control, she'll throw me a design that challenges my every conception of what flexbox is or how it should work. Let's look at a specific point and case--a design I was recently asked to build out:

SASS Compilers: When Your Drupal Theme Won't Update Even After Clearing Cache

Ever feel like you basically spend the entire day hitting your head against a wall? It happens to the best of us--particularly when it comes to elements of DevOps we don't deal with on a daily basis. I spent far longer than I care to admit today trying to assess why my Drupal site theme wasn't updating despite holding my code to a microscope, and despite any number of cache clears. The culprit: the output path on my SASS compiler was set to the wrong folder. Seems like a novice mistake... which is why I'm commemorating it with a blog post: sometimes brain farts are just part of the job.

Background: A New Computer

That's right... I got tired of lugging my laptop between home and the office, so I setup a new computer over at the coworking space. Okay, technically, it's not a new computer at all; it's a 2011 Mac Mini Server running Xubuntu 20.04--still a perfectly reasonable computer for web development in 2021. But, that means "provisioning" the computer for my workflow. Thanks to Git, this is a pretty easy task: install a LAMP stack, clone the repository, setup drush aliases, import a DB, and we're basically good to go...

Except, not really.

Bash: Automate Verbose Error Loggin in Drupal

Turning on verbose error logging in Drupal is an important tool for diagnosing any number of problems. Unless you have the PHP syntax memorized, though, it's a bit of a pain to enable. Even if you keep the $config line commented out in your settings.php file, opening a file editor every time you need to turn it on can also be a pain. Here's a short Bash script that will automatically edit your settings.php file and turn on verbose error logging..

I have a real knack for hitting the WSOD on my localhost--usually when juggling databases and code in between remote and local. As a result, I like to keep verbose error logging commented out in my settings.php. It's generally the last line in the file, somewhere after the $databases array. For privacy reasons I won't screen grab the actual file, but the commented line (for both D8 and D9) should be this:

CSS & Javascript: Flexbox Columns that Grow with Content

I've had a long standing problem with flexbox--particularly with flexbox columns. The proverbial Elephant in the Room has always been this: a mechanism for automatically letting content grow in one column (i.e., adding consecutive child items) and then overflow into the next doesn't really exist. Today, I look at a fix for this problem--and, all it takes is a little JavaScript.

Outlining the Problem

Let's look at flexbox columns and see what's at stake.

Responsive Design: Don't Use the Same JavaScript Function Twice

Empty string passed to getElementByID()? Why you can't just duplicate javascript functions for mobile and desktop elements.
browser console showing empty string error
Arg!

I've got a simple JavaScript function that relies on getElementById(); for some reason, even though the element ID is 100% kosher (it exists), when I run the function my browser console gives me an error: "Empty string passed to getElementById()." Both the problem and the

Drupal Module: Share by Mail Failure in Social Media Share Module

This is a rather otaku (nerdy) error you may find when using the Social Media Share module for D8: when trying to share by mail the browser opens the mail client with an incomplete title and body. Except, it only does it for certain articles. Sounds like a mystery; it's not.
share block
A simple block allowing users to share an article by mail.

A little background: one of my clients recently put together a blog. On that blog, we were careful to put together a custom styled share block using the Social Media Share module--we run the D8 version (8.x-1.8).

How to Kill your Drupal Site: Database Cache

Juggling Git branches between a Production, Staging, Development and Localhost environment can make for exciting errors every now and then. Drupal often labels these errors as 'unexpected'--an obvious but often unhelfpul label. The culprit is often the database cache--here's a real life walk through of how it might be fixed.

Quick note here: I'm working with Drupal 8--although, the process documented here is more or less the same for Drupal 7 or even Drupal 9...

I recently ran some Drupal module updates on our Development site; one of those updates required a database update--namely, the Google Tag Manager module. I brought down the branch with module updates onto my localhost and then imported a copy of my Production database to continue the work on my computer. Upon loading the site, I encountered an unexpected error:

Git Error: Unable to create index.lock

Here's an error I recently came accross in Git when trying to push a commit. If Git is giving you something about being unable to create the index.lock file, it's likely you have a git process running in the background that needs to be resolved before git can move forward.

I was doing some routine updates to Drupal modules today when I got a rather peculiar error: git was unable to create a file called 'index.lock'. I don't know what a lock file is, or why Git even needs to create one, so it caught me by surprise. Reviewing my own terminal, though, and after consulting a thread over at Stack Overflow, It's all clear to me how I ended up where I did. In the end, I fell into the ever enduring trap of not listening to my terminal.