Jul 222018


  • We want to add on a node page layout a block which uses a field from the currently rendered content (node).
  • We want this block to be translated the same as the currently rendered entity.
  • As a anonymous user, we want it to respect the published settings of the currently rendered entity.
  • As an admin, we want to be able to see this block if the content is unpublished.
  • We want to support cases when a content is not translated. The default Drupal behaviour is to use the default translation.



Configuration screenshot.

  • Do not use Published (= Yes) setting.

    Views will remove itself results on which you don’t have permission. Also, as an admin, you will still be able to see the block if the content is unpublished.

  • Set Default translation (= True).

    Views will retrieve the default translation, which is the default result when you attempt to go on a node page which has no translation.

  • Set Rendering Language to Interface text language selected for page.

    Views will attempt to translate the content. If no content translation is found, default translation will be used.

  • Contextual filter set to Content: ID with Content ID from URL as default value.
  • Hide block if the view output is empty.

    No need to keep this block if there is no output (or keep it if you need it anyway).

Additional information

  • Tested on Drupal 8.5.5 on simplytest.me.
May 062018

Here is a little code snippet to be added in a .module file.

Additional Information

  • Instructions made on Drupal 8.5.x.
  • Will break text align buttons in the CKEditor toolbar: Issue on Drupal.org
  • The default behaviour of CKEditor is the following:
    • Enter: inserts a paragraph directly in the WYSIWYG,
    • Shift + Enter: inserts a line break.
  • The new behaviour of CKEditor with the hook will be:
    • Enter: inserts a single line break (br),
    • 2 × Enter: inserts two line breaks which will be converted into a paragraph when rendered.
Jan 282018

When using Search API Page, I needed to theme the search form in the bootstrap structure. The cleanest answer I have found is to add some variables to trigger the bootstrap overrides on the search form.

Additional Information

  • Instructions made on Drupal 8.3.x (probably, haha).
Apr 022017

This article is about the default admin_page, admin_block and admin_block_content templates which serves as the base of the content display on some system configuration pages such as the one on this image:

Screenshot of the configuration page on a Drupal 8 website

Screenshot of the configuration page on a Drupal 8 website

The code


If you use admin_page, you will be able to define the column in which the blocks dwell: left or right.

If you use directly admin_block, there is only a single block and it will span over the full width of the region.

So all in all, here is a pseudo hierarchy to better understand how it works:

Feb 212017



hook_schema is one of those methods where you are happy to have a usable documentation on the api website. It is pretty much self-explanatory and you don’t have to look for hours on third parties websites to get some usable information. 🙂

  • hook_schema on api.drupal.org and don’t forget to select your Drupal version!
  • $DRUPAL_ROOT\core\lib\Drupal\Core\Database\database.api.php: another file which describes the Database API array structure!
  • Schema Reference on drupal.org for D7. Yeah, there is no D8 version of the docs… Hopefully, nothing has changed between D7 and D8.

After some research, I found the files which are responsible for schema to SQL statement conversion:

File location Method name
$DRUPAL_ROOT\core\includes\schema.inc drupal_install_schema (8.2.x)
$DRUPAL_ROOT\core\includes\database.inc (deprecated) db_create_table (8.2.x) (deprecated)
$DRUPAL_ROOT\core\lib\Drupal\Core\Database\Schema.php protected createTable (8.2.x)

The code

Feb 192017


Rendered table from a render array

Rendered table from a render array

The code

Additional Information