[Drupal] Perfect views block configuration for multilingual node support

Objectives 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 …

[Drupal] Change CKEditor behaviour for line breaks (br or p)

Here is a little code snippet to be added in a .module file. /** * Implements hook_editor_js_settings_alter(). * * {@inheritdoc} */ function MODULE_editor_js_settings_alter(array &$settings) { foreach ($settings[‘editor’][‘formats’] as $name => $value) { // Use instead of on enter. // See: https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR.html#property-ENTER_BR. // CKEditor natively converts double into on rendering. $settings[‘editor’][‘formats’][$name][‘editorSettings’][‘enterMode’] = ‘2’; } } Additional …

[Drupal] Make the Search API Page search block appear in Bootstrap markup

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. /** * Implements hook_form_FORM_ID_alter(). */ function MYMODULE_form_search_api_page_block_form_alter(&$form, FormStateInterface $form_state, $form_id) { // We need this to make our search_api_page_block_form …

[Drupal] Base hook schema example to put in .install

Introduction Delighted 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] Table render array example structure

Result The code public function controllerCallbackExample() { return [ ‘#type’ => ‘table’, ‘#caption’ => ‘This is a caption. Use a translated string here.’, ‘#header’ => [ ‘Header 1’, ‘Header 2’, ‘Header 3’, ‘Header 4’ ], ‘#rows’ => [ [ ‘Row 1 Cell 1’, ‘Row 1 Cell 2’, ‘Row 1 Cell 3’, [‘data’ => ‘Row 1 …