Week 6
Working with Drupal 8
These slides contain exercices!
Please make this exercise on an empty Drupal 8 installation.
So you can use an existing installation if there is no content. (so no umami!)
Otherwise install a new one: imdschool
Use the Standard install profile
In Drupal, a Content Type is a pre-defined collection of data types (Fields) which relate to each other by an informational context.
In this sense, "context" means "parts that should be considered as a correlated whole."
All sources of information can be grouped like this.
Like a contractor who has a website showing projects that he has built. The project itself could be a content type containing fields for the name, address, a teaser description, longer text describing the build or materials used, an image album, references to used materials, ...
Then the used materials can be turned into a content type itself. It could support fields like: name, retail identification number, a reference to a retailer, ...
Drupal has 4 distinct parts to a content type:
How a node is displayed depends on the context in which it is viewed, such as the difference between full nodes and teasers.
You can enable more view modes or add custom ones
Add a content type: Course
What type of data the field will store
Each field can store one type of data (text, number, file, etc.).
When you define a field, you choose a particular field type, which corresponds to the type of data you want to store.
The field type cannot be changed after you have created the field.
Machine name is the unique name of the field, all Drupal entities have a machine name. This process is automatic, but can be manually altered.
Can't be changed later.
Depends on the type.
F.e.: Image has a lot more settings.
Sometimes different content types will use very similar fields. If you are sure that the field and its use will be the same for both content-types, than you can re-use existing fields.
This is a very good practise for maintainability.
For example you can use the same Description field on a few content-types and then have a single template in your theme to change the output.
Adding fields
The views module allows administrators and site designers to create, manage, and display lists of content.
Each list managed by the views module is known as a "view", and the output of a view is known as a "display".
Displays are provided in either block or page form, and a single view may have multiple displays.
When you add a view, consider this screen a quick setup wizard.
By making some basic choices, you can easily create a simple view.
Later on you can customise this completely.
default drupal html grid, rather basic
<ul><li>node</li><ul>
<table><tr><td>
<div class="views-row">
view mode teaser
view mode full content
field: title
field: title w/ link
fields: all fields
All of these can be changed & customized later
This does not use your front-ends css/js! Go to the view page for that.
Add a view: Courses
We want to add a new content type called Course. Each Course contains field to describe a school course. It has a Name (title) and a Description (body).
We want to link our Teachers to a Course, so that we can see which Teacher gives what Course.
Meet the reference field.
Create a new Content type called Teacher.
For settings:
This content type has (by default) a title, and a body field.
Works the same way as a Reference field: content, except that it links to a specific/multiple taxonomies.
Taxonomies are managed under structure/taxonomy
Taxonomies (aka vocabulary) are basically lists of items, usually used for categorisation, tagging, etc
There are cases where the administrator manages them, but these can be also be setup to be freely added by users
Add taxonomy: department
One of the great features of Drupal is the ability to control how and what people can access on your site.
You can set permissions for these "users" to define who can do what for Drupal core features and contributed modules.
For example, you probably won't want casual visitors to edit your homepage. However, the site owner or trusted user should be able to do so.
Add user role: Webmaster
Add a new role Webmaster & set permissions.
This user needs to be able to:
Test this user!
Make sure you can do all of the actions listed before!
Protip: use a second browser or incognito window