Tip:
Highlight text to annotate it
X
Now, the first thing that we're going to do is to create a sample module, something that
will allow us to work through the scaffolding of a typical module and also help illustrate
the fact that if you are working within Hooks there is a lot that you can do in Drupal using
the existing skills that you have that you've built working with Drupal 7 or Drupal 6.
So let's head over to our Resource Pack and here you should see a glue folder. You will
also see a number of other folders here but those will be added as we progress through
the series. You'll see them in the Resource Pack now though so don't worry about them
too much at the moment.
Now, let's open up our Drupal installation in a separate tab here so now we can easily
switch back and forth between our Resource Pack and our Drupal installation.
Now, in previous versions of Drupal, we would end up putting our custom modules in the sites
all modules folder. But in Drupal 8, things get a little bit more intuitive and now you
can put modules directly in the modules folder in the base directory of the Drupal site.
So what we'll do is go to our Resource Pack and we'll copy the glue folder. We'll jump
over to our Drupal installation, open up the modules folder, and paste it in. Now, this
folder just has a single subfolder called steps which, if you've used Build A Module
to learn in the past, you are familiar with. The idea is that these are file stubs that
we can use to copy and paste progressively as our examples start to build. So the steps
folder shouldn't affect your module in any way but this will provide us with the base
code for our example as it evolves.
So let's step up in our file directory structure back to our Drupal base directory. So you
see, we now have modules, glue, and then our steps folder.
So our module is going to need two files in order to be enabled by Drupal. It needs a
dot info YAML file and a dot module file.
Now, in future updates to Drupal, you may not need the dot module file at all because
there is legitimate reasons that a module wouldn't have that file. Typically, that file
will contain places where the module uses Hooks. But if the module is just providing
forms or plugins, those things will exist in subdirectories so the dot module file might
not be necessary. For now though, we need them both.
So let's create our two files but empty for now. Okay. So here is our new file, untitled
dot txt but we'll rename this glue dot info dot yml for YAML. And let's create our second
necessary file which will be glue dot module.