Skip to main content
added 112 characters in body
Source Link
norman.lol
  • 19.1k
  • 6
  • 75
  • 129

See the block_example.moduleblock_example.module. It's hook_block_view_alter you can use to do thatthis programmatically. You can probably use thatit in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface; function MYMODULE_block_view_alter(array &$build, BlockPluginInterface $block) { // We'll search for the string 'uppercase'. $definition = $block ->getPluginDefinition(); if (!empty($build['#configuration']['label']) && mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) && mb_strpos($definition['subject'], 'uppercase')) { // This will uppercase the block title. $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']); } } 

Most often you find answers to questions like that really fast when you google for Drupal X how to X programmatically or similar.

See the block_example.module. It's hook_block_view_alter you can use to do that programmatically. You can probably use that in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface; function MYMODULE_block_view_alter(array &$build, BlockPluginInterface $block) { // We'll search for the string 'uppercase'. $definition = $block ->getPluginDefinition(); if (!empty($build['#configuration']['label']) && mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) && mb_strpos($definition['subject'], 'uppercase')) { // This will uppercase the block title. $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']); } } 

Most often you find answers to questions like that really fast when you google for Drupal X how to X programmatically or similar.

See the block_example.module. It's hook_block_view_alter you can use to do this programmatically. You can probably use it in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface; function MYMODULE_block_view_alter(array &$build, BlockPluginInterface $block) { // We'll search for the string 'uppercase'. $definition = $block ->getPluginDefinition(); if (!empty($build['#configuration']['label']) && mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) && mb_strpos($definition['subject'], 'uppercase')) { // This will uppercase the block title. $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']); } } 

Most often you find answers to questions like that really fast when you google for Drupal X how to X programmatically or similar.

deleted 4 characters in body
Source Link
norman.lol
  • 19.1k
  • 6
  • 75
  • 129

See the the block_example.module. It's hook_block_view_alter you can use to do that programmatically. You can probably use that in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface; function MYMODULE_block_view_alter(array &$build, BlockPluginInterface $block) { // We'll search for the string 'uppercase'. $definition = $block ->getPluginDefinition(); if (!empty($build['#configuration']['label']) && mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) && mb_strpos($definition['subject'], 'uppercase')) { // This will uppercase the block title. $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']); } } 

Most often you find answers to questions like that really fast when you google for Drupal X how to X programmatically or similar.

See the the block_example.module. It's hook_block_view_alter you can use to do that programmatically. You can probably use that in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface; function MYMODULE_block_view_alter(array &$build, BlockPluginInterface $block) { // We'll search for the string 'uppercase'. $definition = $block ->getPluginDefinition(); if (!empty($build['#configuration']['label']) && mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) && mb_strpos($definition['subject'], 'uppercase')) { // This will uppercase the block title. $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']); } } 

Most often you find answers to questions like that really fast when you google for Drupal X how to X programmatically or similar.

See the block_example.module. It's hook_block_view_alter you can use to do that programmatically. You can probably use that in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface; function MYMODULE_block_view_alter(array &$build, BlockPluginInterface $block) { // We'll search for the string 'uppercase'. $definition = $block ->getPluginDefinition(); if (!empty($build['#configuration']['label']) && mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) && mb_strpos($definition['subject'], 'uppercase')) { // This will uppercase the block title. $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']); } } 

Most often you find answers to questions like that really fast when you google for Drupal X how to X programmatically or similar.

added 142 characters in body
Source Link
norman.lol
  • 19.1k
  • 6
  • 75
  • 129

See the the block_example.module. It's hook_block_view_alter you can use to do that programmatically. You can probably use that in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface; function MYMODULE_block_view_alter(array &$build, BlockPluginInterface $block) { // We'll search for the string 'uppercase'. $definition = $block ->getPluginDefinition(); if (!empty($build['#configuration']['label']) && mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) && mb_strpos($definition['subject'], 'uppercase')) { // This will uppercase the block title. $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']); } } 

Most often you find answers to questions like that really fast when you google for Drupal X how to X programmatically or similar.

See the the block_example.module. It's hook_block_view_alter you can use to do that programmatically. You can probably use that in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface; function MYMODULE_block_view_alter(array &$build, BlockPluginInterface $block) { // We'll search for the string 'uppercase'. $definition = $block ->getPluginDefinition(); if (!empty($build['#configuration']['label']) && mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) && mb_strpos($definition['subject'], 'uppercase')) { // This will uppercase the block title. $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']); } } 

See the the block_example.module. It's hook_block_view_alter you can use to do that programmatically. You can probably use that in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface; function MYMODULE_block_view_alter(array &$build, BlockPluginInterface $block) { // We'll search for the string 'uppercase'. $definition = $block ->getPluginDefinition(); if (!empty($build['#configuration']['label']) && mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) && mb_strpos($definition['subject'], 'uppercase')) { // This will uppercase the block title. $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']); } } 

Most often you find answers to questions like that really fast when you google for Drupal X how to X programmatically or similar.

added 174 characters in body
Source Link
norman.lol
  • 19.1k
  • 6
  • 75
  • 129
Loading
Source Link
norman.lol
  • 19.1k
  • 6
  • 75
  • 129
Loading