O'Reilly logo

Drupal 8 Development Beginner's Guide - Second Edition by Kurt Madel, Malabya Tewari, Rakesh James, Krishna Kanth, Edward Crompton, Samuel Keen, Tassos Koutlas, Neeraj Kumar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating a block to aid the authoring experience

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:

  1. Create a structure similar to what we saw in the last screenshot.
  2. 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
  3. 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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required