You are here

Things that annoy me about Drupal 8

1. Placing blocks for the first time

Disabled blocks do not appear in the disabled blocks section of the blocks admin page.
This took me a couple of hours to find. Here is what you do:

On the bottom of the page admin/structure/block it says:

Disabled (Place block)
No blocks in this region

  • This is in fact untrue, since there are blocks in this region but they are hidden.
  • You can make them visible by pressing the (Place block) button, which will show them, and then placing them in a different region.

2 Code Sometimes has to go in Comments

I am somewhat disturbed by the idea that some of the code should be contained in comments. (E.g. the FilterBase class has the default settings for a new filter instance in the header comments). I understand that this is necessary because of the limitations of the expressiveness of the language, but I feel that comments should be comments, even though it might be a good idea to standardize the formatting to help readability and automatic documentation tools.

3. Very complex code to create links

  • Suppose a module needs to create some text that includes a link to another page. The goal is to simply generate:
    For more info, see the <a href='/information'>information page</a>

Drupal 7 links solution

'#markup' => t('For more info, see the ') . l(t(information page', '/information'),
or
'#markup' => t('For more info, see the @information_page',
               array(
                 '@information_page' => l(t(information page', '/information'),
               )
              ),

Drupal 8 links solution

use Drupal\Core\Url;
use Drupal\Core\Link;
$sample_url_obj = Url::fromUri('/information); // or if route available: Url::fromRoute('sample.information');
$sample_link_obj = Link::fromTextAndUrl($this->t('sample sub page'), $sample_url_obj);

'#markup' => t('For more info, see the @information_page',
               array(
                 '@information_page' => \Drupal::service('renderer')->render($sample_sub_link_obj->toRenderable()),
               )
              ),
Topic: