Skip to main content
remove D8 from title, add tag, format code
Source Link
4uk4
  • 101.7k
  • 7
  • 173
  • 217

Create a custom block programmatically and specify region and pages on which created block must shown on. Drupal 8

For create block programmatically I use

        $block = BlockContent::create([
        info''info' => 'block 3',
  'type' => 'basic',
  'langcode' => 'en',
    'body' => [
 
    'value' => '<h1>Block's body</h1>',
    'format' => 'full_html',
                      ],
                       ]);
 
                   $block->save();

It works good enough but is it possible also to specify region and then on which pages created block must shown on?

Create block programmatically and specify region and pages on which created block must shown on. Drupal 8

For create block programmatically I use

        $block = BlockContent::create([
        info' => 'block 3',
'type' => 'basic',
 'langcode' => 'en',
    'body' => [
 
  'value' => '<h1>Block's body</h1>',
'format' => 'full_html',
                      ],
                       ]);
 
                   $block->save();

It works good enough but is it possible also to specify region and then on which pages created block must shown on?

Create a custom block programmatically and specify region and pages on which created block must shown on

For create block programmatically I use

$block = BlockContent::create([
  'info' => 'block 3',
  'type' => 'basic',
  'langcode' => 'en',
  'body' => [
    'value' => '<h1>Block's body</h1>',
    'format' => 'full_html',
  ],
]);
$block->save();

It works good enough but is it possible also to specify region and then on which pages created block must shown on?

Source Link
Czaa
  • 63
  • 1
  • 7

Create block programmatically and specify region and pages on which created block must shown on. Drupal 8

For create block programmatically I use

        $block = BlockContent::create([
        info' => 'block 3',
'type' => 'basic',
 'langcode' => 'en',
    'body' => [

  'value' => '<h1>Block's body</h1>',
'format' => 'full_html',
                      ],
                       ]);

                   $block->save();

It works good enough but is it possible also to specify region and then on which pages created block must shown on?