Add an example showing how the content of a block is changed at runtime

Created on 11 July 2017, almost 8 years ago
Updated 14 July 2024, 9 months ago

The Block Example has Example: empty block which is not rendered when placed into a region. Would be it useful to demonstrate how to fill it with the content in the block_example_block_view_alter().

📌 Task
Status

Needs work

Version

4.0

Component

Block Example

Created by

🇪🇪Estonia drugan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    We need to use merge requests instead of patches.

    Given the comments in that class, the empty array is returned on purpose, to show that empty blocks are not added to pages.

      /**
       * {@inheritdoc}
       *
       * The return value of the build() method is a renderable array. Returning an
       * empty array will result in empty block contents. The front end will not
       * display empty blocks.
       */
    
        // We return an empty array on purpose. The block will thus not be rendered
        // on the site. See BlockExampleTest::testBlockExampleBasic().
    

    An example showing how the content of a block is changed at runtime can be added, but it needs to alter a different block.

Production build 0.71.5 2024