Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules


9.4. Creating pages for a premium account.

24/09/2019, by mikhail

In this lesson, we will expand the capabilities of our module and create content that will be available only to registered users or users with a specific role.

Code examples can be viewed on github:


Let's start by adding a new YML file right in our drupalbook.permissions.yml module folder:

access premium pages:
  title: 'Access Premium pages'
  description: 'A custom permission for your pages.'
  restrict access: TRUE

Now go to the access rights page and set access to Premium content for the necessary roles, I will do this for registered users:



Now in drupalbook.routing.yml create a new route, in which we indicate our new rights and a new method for displaying content:

   path: '/private-page'
     _controller: '\Drupal\drupalbook\Controller\FirstPageController::privateContent'
     _title: 'Private content'
     _permission: 'access premium pages'

After adding a new route, you need to clear the cache.

We will also need to add the privateContent () method to our FirstPageController class:

 * Returns a private page.
 * @return array
 *   A simple renderable array.
public function privateContent() {
  $element = array(
    '#markup' => 'Private content',
  return $element;

Now you can clear the cache and verify that our page is not accessible to unregistered users.


Code examples can be viewed on github: