Let's create a custom block that will be available to authenticated users to create new recipes when visiting a recipe page. Our module will be called author_tool
:
Create a structure similar to what we saw in the last screenshot.
Create a
author_tool.info.yml
file and create a dependency of your module with the block system:name: Author tool type: module description: A custom block to allow content editors to quickly add a new recipe. core: 8.x dependencies: - block
Extend the
BlockBase
class with your own implementation,AuthorToolBlock
, and place the following code in it:<?php /** * @file * Contains \Drupal\author_tool\Plugin\Block\AuthorToolBlock.php. */ namespace Drupal\author_tool\Plugin\Block; use Drupal\Core\Block\BlockBase; /** * Provides a custom block. * * Drupal\Core\Block\BlockBase gives us a very useful set of basic functionality * for this configurable block. We can just fill in a few of the blanks...