Create custom block programmatically
how to create a custom block in Drupal 10
https://www.youtube.com/watch?v=1x7ntRl3a74
How to create custom block programmatically in Drupal 9?
https://www.youtube.com/watch?v=49psk1jLpYE
How to embed inline javascript in Drupal, anywhere on any page
class MyJavascriptBlock extends BlockBase { public function build() {
$js = \Drupal::config('mymodule.settings')->get('js_file_url') $tag = '<script type="text/javascript" src="'.$js.'"></script>'; return [
'#markup' => $tag,
'#allowed_tags' => ['script'],
];
}}
留言
發佈留言