How do I create a Drush command

Submitted by drupalviking on Mon, 09/14/2020 - 10:20

Here is how I scaffold a module to be able to run Drush commands.

First, I create the module with Drupal Console: drupal generate:module

Then, I have to create the file drush_services.yml and include this in it:

services:
  MY_MODULE.commands:
  class: \Drupal\MY_MODULE\Commands\WHATEVERINAMEMYCLASSCommands
  tags:
    - { name: drush.command }

How the hell do I push data from Drupal into Javascripts (Drupal 7)

Submitted by drupalviking on Wed, 03/07/2018 - 12:13

So here was my scenario:

I was creating an edit form for node type for a customer. When the node was originally submitted, the user could choose a location from a map, and the coordinates were saved in the node. And now, when a registered user is editing the node, he needs to see the map with the coordinates in place.

How I setup my work computer

Submitted by drupalviking on Thu, 02/22/2018 - 18:23

Few weeks ago I was getting fed up with how my computer was set up. Sometimes it’s just the time … time to wipe it clean and give it a clean slate.

But that can cause problems. I have so many configurations on my computer, due to the fact that I’m a developer. PHP, Apache, Mysql, Drush, Composer, Drupal Console, XDebug …. The list is endless. And my biggest problems are: I ALWAYS FORGET HOW TO DO IT! :-D 

How to use Media Entity asset as a background image

Submitted by drupalviking on Wed, 09/13/2017 - 14:33

So, I have been using the new Media Entity module, along with some of the other media modules on some websites, and generally I like it. I find it awesome to be able to create different Entity Browsers, based on tagging, so if I'm adding hero images to my Hero Image block, my entity browser can have a special view.

In order to use the Hero image from my block as a background image, I had to Google a little. Hence my post, I wanted to document what I did, if for nothing else, my own reference. So here we go.

Configuring Gulp to be used with your Bootstrap Starter Kit

Submitted by drupalviking on Wed, 08/09/2017 - 09:27

There are so many tools out there to use, it's really easy to get distracted and not really know what to use. For a long time I just use Compass to compile my scss files into CSS, but there is so many other things you could be doing too. So when I discovered Gulp, I started to use it, and it helps a lot when I'm theming.

Configure your development environment for Theming

Submitted by drupalviking on Wed, 08/09/2017 - 09:10

One of the first things that I do when I start a new project is to configure my environment as development, to react on what I'm doing, specially when I'm theming. Disable cache, enable debug messages and more. These steps are among the ones that I always do:

Setting up my settings.local.php file

Go to the sites/ folder of your project and copy example.settings.local.php to the folder like this: cp example.settings.local.php default/settings.local.php (renaming it to settings.local.php in the process).

Media

Submitted by drupalviking on Thu, 08/03/2017 - 09:58

Handling media in Drupal has been … let’s just admit it .... horrible. Even in Drupal 7, the Media module didn’t really handle media very well. The only module who came close was Scald, but it was a cumbersome module to work with and required quite a skillset to install and configure.

My first impression on Drupal 8

Submitted by drupalviking on Thu, 08/03/2017 - 09:31

So, Drupal 8 is the new kid on the block. And whoa, is that the most popular person on the prom! The three major things (and there are hundreds more) that I like about D8 are the fact that you can (and should!) control all Drupal downloads with Composer.  Everything else is just crazy. And the other two things are Configuration Management and Drupal Console.