Skip to content

Instantly share code, notes, and snippets.

View megclaypool's full-sized avatar

Meg Claypool megclaypool

View GitHub Profile
  1. Install the Sidebery extension
  2. In Firefox, open about:support
  3. Scroll down to Profile Folder and click the Show in Finder button
  4. Within the gobbldygook folder that appears, open the chrome folder.
  5. Open the userChrome.css file in a text editor.
  6. Paste the contents of the sidebery.css file into it
  7. Relaunch Firefox

Ok, so

  • $thingie is your node, or paragraph, or whatever. You're probably writing this code in your thingie's preprocess hook
  • field_reference is the entity reference field that's referring to your taxonomy term whose inner data you want to plunder
  • desired_field is the actual field inside the taxonomy term whose data you need
// Make sure the field exists and isn't empty
if ($thingie->hasField('field_reference') && !$thingie->get('field_reference')->isEmpty()) {
  // This is a taxonomy term reference, so I need to get the term id, then load it to get the term data.
  $termreference = $thingie->get('field_reference')->target_id;

Ok, so

  • $thingie is your node, or paragraph, or whatever. You're probably writing this code in your thingie's preprocess hook
  • field_paragraph is a paragraph field whose inner data you want to plunder
  • desired_field is the actual field inside the paragraph whose data you need
// First, check that the field exists and isn't empty
if ($thingie->hasField('field_paragraph') && !$thingie->field_paragraph->isEmpty()) {
  
  // In this case, this is a single value field. Otherwise you might need to set up a loop or call a specific entry

Redirecting visitors from an auto-generated taxonomy term page to a node (like a landing page) is totally doable, but there's a trick to it!

You can't just type the auto-generated url for the taxonomy term into the redirect; for whatever reason it just doesn't work. (For example, "resource-types/law-overviews" wouldn't work.) Instead, you need to use the taxonomy term number.

Go to the term listing page for the taxonomy. Click or hover over the edit button to get the edit url, which incldes the term number.

Then in the redirect, you put /taxonomy/term/THE-TERM-NUMBER-YOU-JUST-FOUND into the "From" field, and use autocomplete to select the desired node "To" field.

ex: From: /taxonomy/term/118

@megclaypool
megclaypool / breadcrumbs.md
Created March 11, 2025 22:19
[Easy Breadcrumb Path Replacements (Drupal)]

Ok, I finally figured out how the "Paths to replace with custom breadcrumbs" section of the Easy Breadcrumbs settings works!

  1. Each line is a separate breadcrumb.
  2. Each section of a line is separated with ::
  3. The first section is the chunk you want to replace.
  4. Then each section after that is a chunk of breadcrumb
  5. If you want your breadcrumb chunk to link somewhere, put in a pipe (|) followed by the url to link to

ex:

@megclaypool
megclaypool / error-and-solution.md
Last active April 8, 2025 14:03
[Troubleshooting Lando: Errors and Solutions]

Error

error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out

Solution

The solution is to delete my docker config file: rm ~/.docker/config.json

Error

PHP Warning: include(/app/vendor/bin/../composer/composer/bin/composer): Failed to open stream: No such file or directory in /app/vendor/bin/composer

Solution

@megclaypool
megclaypool / notes.md
Last active February 19, 2025 18:52
[How to change the name a Mac app displays in the menu bar] [Answer from AskDifferent](https://apple.stackexchange.com/a/385074/225185) I use this to rename "Firefox Developer Edition" to "FF Dev" so my menu bar doesn't overflow!

Renaming the .app package in Finder only changes the name there, it doesn't change the name shown in the menu. To do so edit YOUR.app/Contents/Resources/XY.lproj/InfoPlist.strings (with XY being the language you are using) and change CFBundleName there.

For applications without localization files you can also edit YOUR.app/Contents/Info.plist and set a new value for CFBundleName there.

Managing CSS and JavaScript files in Drupal 8 with Libraries

Thought byDavid Hernandez March 14, 2016 Drupal 8 CSS and JavaScript

Drupal 8 revolutionizes the theming experience with many significant improvements to make theming easier, and give themers the flexibility and control they've never had before. One of those major improvements is to the library management system, which controls the attaching of CSS and JavaScript files.

In this post we will cover how to create and control libraries from a theme. This will include SMACSS categorization for CSS files, dependencies, how to conditionally attach libraries, manipulating libraries that come from anywhere in a site (core, modules, or base themes,) and targeting individual files for removal or replacement. All this without needing a single line of PHP. Creating Libraries