Installing Library Using Drupal & Composer

The instructions on on how to install a library using composer suck. Or maybe I’m just doing it wrong? I don’t know. But it happened again. I need another library from some outside source.

I thought I just needed to modify my composer.json file and run composer install and it was good but I forgot the other step.

You also need to run composer require and whatever you named your library.

Here’s the code from my composer.json:

			"type": "package",
			"package": {
				"name": "addon/youtube",
				"version": "2.1.18",
				"type": "drupal-library",
				"dist": {
					"url": "",
					"type": "zip"

Save the file. Then run:

$ composer require addon/youtube

That should do it. Maybe run another $ composer install so everything is good.

Background Opacity Affecting Text Opacity

Why do I always forget this? Hopefully I’ll remember why this happens this time with a simple blog post!

When you add opacity to a div, it affects the text opacity as well. Ex.

Your CSS is something like this:

.header_background {
	opacity: .8;
	color: #FFFFFF;
	background-color: #475260;

Do not just use opacity like that. Use it like this:

.header_background {
	color: #FFFFFF;
	background: rgba(47, 52, 60, .8);

Now it’s nice:

Change Theme To Admin For Custom Module Page

I’ll forgo the PROBLEM/SOLUTION in this one since it’s so quick.

I wanted to make the pages (forms) of a custom module I was creating use the admin theme instead of the public facing theme. Turns out it was really easy.

In the .routing.yml file, add the following:

    _admin_route: TRUE

So a cleaned-up example of the yml looks like this:

  path: '/whatever/your/path/is'
    _form: '\Drupal\module_name\Form\WhateverYourFormIs'
    _title: 'Page/Form Title'
    _role: 'authenticated'
    _admin_route: TRUE

Need this in my arsenal.

Views Exposed Filter Query Strings

This post is just something I found out that I will need to remember.

With views, when I have an exposed filter, what ends up in the query string matters. I would like a clean look so the URL can be something like ?taxonomy=research . I had set up a view so it does do that but then when I went to set up another one, it used the taxonomy id (i.e. ?taxonomy=345 ). How did it get that way?

It’s all about how you set up the exposed filter in the view. In your view, in the Settings, next to the exposed filter under FILTER CRITERIA, when you select what specific taxonomy to use, you’ll see an option at the very bottom for Selection type. This could be either Dropdown or Autocomplete.

If you select Dropdown, it will use the taxonomy id in the URL (i.e. ?taxonomy=345 ).

If you select Autocomplete, it will use the taxonomy name in the URL (i.e. ?taxonomy=research ).

Have to remember that. But it would be nice for Views to give you the option.

Disable Caching On Specific View In Drupal 8

I may be the only one who struggled with this for a good half hour… and in Drupal time, that’s nothing. I have a view that’s a block of a random piece of content. Unfortunately, Drupal caches everything. So how do I get it to display something random if it doesn’t display something random until the cache is refreshed in Drupal?

Turns out it was easy! (It’s not easy to find the solution online, however.)

In the view, under the Advanced tab, there is Caching. Turn that to none.

That’s it! Have to remember that!

Composer/Drush Notes For Drupal 8

While I had some time, I thought I might create a post for some composer and drush commands that I use A LOT… just for a reference.

This list is for Drupal 8/Drush 9.

Command What It Does
$ drush cr Clears cache (duh; you use this 1239832 times a day)
$ drush en coder Enable a module (ex. coder)
$ drush pmu coder Disable a module (ex. coder)
$ composer require drupal/coder Install a module (ex. coder)
$ composer remove drupal/coder Uninstall a module (ex. coder); disable it first!
$ composer require drupal/migrate_tools:4.0-beta2 Install a specific version of a module (ex. migrate tools)
$ drush sql-dump –-result-file=’/path/to/database/backup.sql’ Get a database backup easy
$ composer update Update Drupal 8 core & modules
$ drush updb Update the database after a Drupal core and/or module update (duh; do this after you run composer update; same as going to update.php)
$ drush status Tells you important information such as Drupal version, Drush version, etc.
$ drush sqlc Get into the database (MySQL) easy
$ drush uli Get a temporary URL to log into the Drupal site to bypass password; good for when you lose your password or your account is locked out and you’re the admin
$ drush sql-connect The database connection string
$ composer -V The version of composer you’re running
$ drush user-create janny_m –mail=”” –password=”my_p@ssword” Create a user (janny_m) with email and password
$ drush user-add-role “administrator” janny_m Make a user an administrator
$ sudo /usr/local/bin/composer self-update Update composer

Stop Caching In Drupal 8 Custom Module Block

I created a custom module for next/previous posts since there isn’t one out there for D8. And even if one is out there, it wouldn’t fit our needs since we have different taxonomies and different blogs.

I ran into this caching of blocks issue I had when I developed the flex_carousel module for D8 and it was super annoying. I worked around it using JQuery. I wasn’t happy about that solution.

Now I ran into this issue again; and this time it cannot be JSed around. It needs to not cache.

I developed the module to display next/previous posts when you’re on a blog content type. It works fine if you’re always on the same node but you’re always not on the same node so in other words, it doesn’t work. It keeps the same next/previous posts no matter what node you’re on.

Caching needs to be turned off for this block!
Add this simple function (method) to your block class. Looks something like…

class NextPreviousPost extends BlockBase {
	public function build() {
		/* your build code here */

	 * {@inheritdoc}
	public function getCacheMaxAge() {
		return 0;

It’s that simple! It changed my life.

Default Drupal 8 Module

I may need this for later for module development with Drupal 8. It took me a while to figure out how to do it so I thought I’d post it.

Start of Flex Carousel module

Put this in the /modules/ folder. It is just a blue print to start a Drupal 8 module. It also contains block region functionality for the module.

I’m still very much learning Drupal 8 in the free time I have at work. Interesting stuff so far but I much prefer Drupal 7 since I’m a lot more used to it and it’s more straightforward, in my opinion.

SharePoint 2013 Notes I

Well here’s another post of nifty things to remember. I’m working with SharePoint 2013 (YUCK!) and I ran into a few idiotic idiosyncrasies about it. Here’s a quick post.

Classic SharePoint Breadcrumbs

SharePoint breadcrumbs are hidden in 2013. They’re not included in the default master page… WTF? And when you enable them in your master page (if you can even figure out how to modify the master page), they’re really stupid. They’re a drop down.

First let’s talk about the master page for a sentence or two… The new master pages are only modifiable via their HTML counterpart. So make a copy of the default seattle.html “master page” and that will create another one for you. Rename it as you like and it’s .master will be renamed too. Really stupid, huh?

So you’re just supposed to remove the display: none on the .ms-breadcrumb-dropdownBox div and that brings back the “breadcrumb” but it’s not your typical breadcrumb. It’s a dropdown breadcrumb which sucks ass.

Want a normal breadcrumb? Here’s the code…

<div class="less_crappy_sharepoint_breadcrumb">

Add this right below the .ms-breadcrumb-top div is what I did. I also removed the crappy suck ass breadcrumb since it’s useless to display it then hide it with CSS. Useless!

Styles In The Masterpage

Apparently since everything is done with this .html file, any ASP code or any other code in style tags (probably script as well) has to be “commented out.” Use the following if you want to put styles in your master page.

<!--MS:<style type="text/css">-->
.ms-core-listMenu-horizontalBox li.static > a {
    display: none !important;

Lame, huh?

Oh, and watch out. For some reason SharePoint 2013 don’t do the > anymore so you’re probably going to have to put things like that in the style sheet… (always a good idea anyway).

Hiding The First Top Menu Item

How stupid is this? By default your site name is next to the logo… like you need it twice or something. Want it gone? Tough cookies. You’ll have to hide it with CSS.

Here’s your CSS:

.ms-core-listMenu-horizontalBox li.static > a {
    display: none !important;
.ms-core-listMenu-horizontalBox li.static > ul a {
    display: block !important;

Stupid! I hate SharePoint and I hate SharePoint 2013! How can anyone think this CMS is good. It’s a heavy footprint and look at all the work you have to do for basic things!

I might update this post with more stuff you shouldn’t have to do to get SharePoint to look and function the way websites should OOTB.

#SharePointGetALife #SharePointYouSuck #SharePointWTF

Drupal 7 Notes I

Well this post isn’t exactly a PROBLEM/SOLUTION post but more of an entry to put the few things I need to remember on Drupal 7. Here are three things I should remember for the next time I need help with it. I’m naming it I just in case I want more than one.

Limit Site Search Results By Content Type

If you ever need to exclude some content types from the site search, do the following:

  1. Install and enable the search_config module.
  2. Go to #overlay=admin/people/permissions%23module-search_config and at the bottom you can limit anonymous users by content type.

Remove Authoring Information From Search Results

On the search results page, by default, the authoring information is displayed. This kind of stuff should be turned off my default (in my opinion) since sites usually do not expose this information to the user. Only blogs or news articles have author info so it should be turned off for site search, on pages, etc but that’s a different vent. Anyway to turn this information off, do the following:

  1. In /modules/search copy the search-result.tpl.php and paste it into the theme root (like /sites/all/themes/your_theme/ )
  2. Remove the authoring information code.
  3. Save the page.
  4. Clear the Drupal cache.

Search Title & Content Body In View Block

  1. In the view, select the Tontent: Title and Content:Body under the Fields
  2. If you do not want the Body (or any other thing exposed in the list) select the “Exclude from display” in the Configure field: Content:Body.
  3. Under Filter Criteria, choose the “Global: Combine fields filter”.
  4. Check the “Expose this filter to visitors, to allow them to change it”, “Single filter”.
  5. For the Operator, choose “Contains” and select both/all fields under “Choose fields to combine for filtering”.

Permissions On The /sites/default/files Folder

I struggled with permissions issues for like two days. Between going back and forth with IT on what’s allowed and what isn’t allowed. Blogs everywhere say that the files directory should be 777. But that’s access to everything for everybody.

Ours has this access for the directory:


Every folder underneath this one should be granted the same privileges. By the way, this is on a UNIX box.