code

Title of the current page manager page.

When trying to get the title of the current page manager panels page in Drupal 7 and drupal_get_title() isn't working, try this one:

$page = page_manager_get_current_page();
$page_title = $page['handler']->conf['display']->get_title();

Dynamically define blocks in Drupal 8 with derivatives

During the Drupal 8 port of my relatively new Mefibs module I realized that block creation in code got somewhat more complex than it used to be in Drupal 7 and earlier. It took me quite a while to figure out how this works, especially because there is not a lot of documentation for Drupal 8 yet. So I had to dig my way through core to see how it's done there and finally I got around it. The following is a comparison between how we used to do this in Drupal 7 and how it's done in Drupal 8.

Use field markup for any value anywhere.

Sometimes I just want to display specific pieces of information in, say, a node view. For styling reasons it is often preferable to have the same kind of basic wrapper markup as for fields. This would be particularly useful for pseudo fields that can be declared using hook_extra_fields. Those pseudo fields act almost like real fields in the Fields UI, meaning I can position them just like real fields, put them into groups, etc.