Create a simple block with an image inside with Drupal Console

DrupalConsole is not only intended for developers. It also can be useful for site builders, themers or sysadmins.

In this short post we'll see a basic task, intended for site builders: creating a new block with an image inside. It can work as a banner or any badge you want to show in your site.

Ok, let's go.
First, we need to create a module for attaching to it the Banner Block code.


Once we have created our module for this new block, we can generate the proper block


Pay attention to the region you want the block to be displayed.

Now we can edit the extending BlockBase class recently created and we must edit its build() function.
This function manages the HTML content of the block. You can put the link to a image or whatever HTML element you want there.


Now, we must to install our module. Otherwise, our block won't show up.


Now in the admin structure of the blocks page, our block should appear under the region we selected when we created it.


Now you should see you new & shiny block :D


This is a very basic and simple task using DrupalConsole, but very effective and consider it can be accomplished even but non-programmers!


Añadir nuevo comentario

Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, refresh the CAPTCHA or submit the form and a new image will be generated. Not case sensitive.