Issue #2938900 by David_Rothstein, navneet0693, JayKandari: Replace profile-defined blocks with custom blocks to fix a variety of problems
parent
aa3dcb5b93
commit
b1e477ec25
|
@ -0,0 +1,7 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: disclaimer_block
|
||||
label: 'Disclaimer block'
|
||||
revision: 0
|
||||
description: 'A disclaimer block contains disclaimer and copyright text.'
|
|
@ -0,0 +1,7 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: footer_promo_block
|
||||
label: 'Footer promo block'
|
||||
revision: 0
|
||||
description: 'A footer promo block contains a title, promo text, and a "find out more" link.'
|
|
@ -0,0 +1,39 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- block_content.type.disclaimer_block
|
||||
- field.field.block_content.disclaimer_block.field_copyright
|
||||
- field.field.block_content.disclaimer_block.field_disclaimer
|
||||
module:
|
||||
- text
|
||||
id: block_content.disclaimer_block.default
|
||||
targetEntityType: block_content
|
||||
bundle: disclaimer_block
|
||||
mode: default
|
||||
content:
|
||||
field_copyright:
|
||||
weight: 28
|
||||
settings:
|
||||
rows: 5
|
||||
placeholder: ''
|
||||
third_party_settings: { }
|
||||
type: text_textarea
|
||||
region: content
|
||||
field_disclaimer:
|
||||
weight: 27
|
||||
settings:
|
||||
rows: 5
|
||||
placeholder: ''
|
||||
third_party_settings: { }
|
||||
type: text_textarea
|
||||
region: content
|
||||
info:
|
||||
type: string_textfield
|
||||
weight: -5
|
||||
region: content
|
||||
settings:
|
||||
size: 60
|
||||
placeholder: ''
|
||||
third_party_settings: { }
|
||||
hidden: { }
|
|
@ -0,0 +1,48 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- block_content.type.footer_promo_block
|
||||
- field.field.block_content.footer_promo_block.field_content_link
|
||||
- field.field.block_content.footer_promo_block.field_summary
|
||||
- field.field.block_content.footer_promo_block.field_title
|
||||
module:
|
||||
- link
|
||||
id: block_content.footer_promo_block.default
|
||||
targetEntityType: block_content
|
||||
bundle: footer_promo_block
|
||||
mode: default
|
||||
content:
|
||||
field_content_link:
|
||||
weight: 3
|
||||
settings:
|
||||
placeholder_url: ''
|
||||
placeholder_title: ''
|
||||
third_party_settings: { }
|
||||
type: link_default
|
||||
region: content
|
||||
field_summary:
|
||||
weight: 2
|
||||
settings:
|
||||
rows: 5
|
||||
placeholder: ''
|
||||
third_party_settings: { }
|
||||
type: string_textarea
|
||||
region: content
|
||||
field_title:
|
||||
weight: 1
|
||||
settings:
|
||||
size: 60
|
||||
placeholder: ''
|
||||
third_party_settings: { }
|
||||
type: string_textfield
|
||||
region: content
|
||||
info:
|
||||
type: string_textfield
|
||||
weight: 0
|
||||
region: content
|
||||
settings:
|
||||
size: 60
|
||||
placeholder: ''
|
||||
third_party_settings: { }
|
||||
hidden: { }
|
|
@ -0,0 +1,29 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- block_content.type.disclaimer_block
|
||||
- field.field.block_content.disclaimer_block.field_copyright
|
||||
- field.field.block_content.disclaimer_block.field_disclaimer
|
||||
module:
|
||||
- text
|
||||
id: block_content.disclaimer_block.default
|
||||
targetEntityType: block_content
|
||||
bundle: disclaimer_block
|
||||
mode: default
|
||||
content:
|
||||
field_copyright:
|
||||
weight: 2
|
||||
label: hidden
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
type: text_default
|
||||
region: content
|
||||
field_disclaimer:
|
||||
weight: 1
|
||||
label: hidden
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
type: text_default
|
||||
region: content
|
||||
hidden: { }
|
|
@ -0,0 +1,43 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- block_content.type.footer_promo_block
|
||||
- field.field.block_content.footer_promo_block.field_content_link
|
||||
- field.field.block_content.footer_promo_block.field_summary
|
||||
- field.field.block_content.footer_promo_block.field_title
|
||||
module:
|
||||
- link
|
||||
id: block_content.footer_promo_block.default
|
||||
targetEntityType: block_content
|
||||
bundle: footer_promo_block
|
||||
mode: default
|
||||
content:
|
||||
field_content_link:
|
||||
weight: 2
|
||||
label: hidden
|
||||
settings:
|
||||
trim_length: 80
|
||||
url_only: false
|
||||
url_plain: false
|
||||
rel: ''
|
||||
target: ''
|
||||
third_party_settings: { }
|
||||
type: link
|
||||
region: content
|
||||
field_summary:
|
||||
weight: 1
|
||||
label: hidden
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
type: basic_string
|
||||
region: content
|
||||
field_title:
|
||||
weight: 0
|
||||
label: hidden
|
||||
settings:
|
||||
link_to_entity: false
|
||||
third_party_settings: { }
|
||||
type: string
|
||||
region: content
|
||||
hidden: { }
|
|
@ -0,0 +1,20 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- block_content.type.disclaimer_block
|
||||
- field.storage.block_content.field_copyright
|
||||
module:
|
||||
- text
|
||||
id: block_content.disclaimer_block.field_copyright
|
||||
field_name: field_copyright
|
||||
entity_type: block_content
|
||||
bundle: disclaimer_block
|
||||
label: Copyright
|
||||
description: ''
|
||||
required: false
|
||||
translatable: true
|
||||
default_value: { }
|
||||
default_value_callback: ''
|
||||
settings: { }
|
||||
field_type: text_long
|
|
@ -0,0 +1,20 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- block_content.type.disclaimer_block
|
||||
- field.storage.block_content.field_disclaimer
|
||||
module:
|
||||
- text
|
||||
id: block_content.disclaimer_block.field_disclaimer
|
||||
field_name: field_disclaimer
|
||||
entity_type: block_content
|
||||
bundle: disclaimer_block
|
||||
label: Disclaimer
|
||||
description: ''
|
||||
required: false
|
||||
translatable: true
|
||||
default_value: { }
|
||||
default_value_callback: ''
|
||||
settings: { }
|
||||
field_type: text_long
|
|
@ -0,0 +1,22 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- block_content.type.footer_promo_block
|
||||
- field.storage.block_content.field_content_link
|
||||
module:
|
||||
- link
|
||||
id: block_content.footer_promo_block.field_content_link
|
||||
field_name: field_content_link
|
||||
entity_type: block_content
|
||||
bundle: footer_promo_block
|
||||
label: 'Find out more link'
|
||||
description: ''
|
||||
required: false
|
||||
translatable: true
|
||||
default_value: { }
|
||||
default_value_callback: ''
|
||||
settings:
|
||||
link_type: 17
|
||||
title: 2
|
||||
field_type: link
|
|
@ -0,0 +1,18 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- block_content.type.footer_promo_block
|
||||
- field.storage.block_content.field_summary
|
||||
id: block_content.footer_promo_block.field_summary
|
||||
field_name: field_summary
|
||||
entity_type: block_content
|
||||
bundle: footer_promo_block
|
||||
label: 'Promo text'
|
||||
description: ''
|
||||
required: false
|
||||
translatable: true
|
||||
default_value: { }
|
||||
default_value_callback: ''
|
||||
settings: { }
|
||||
field_type: string_long
|
|
@ -0,0 +1,18 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- block_content.type.footer_promo_block
|
||||
- field.storage.block_content.field_title
|
||||
id: block_content.footer_promo_block.field_title
|
||||
field_name: field_title
|
||||
entity_type: block_content
|
||||
bundle: footer_promo_block
|
||||
label: 'Promo title'
|
||||
description: ''
|
||||
required: false
|
||||
translatable: true
|
||||
default_value: { }
|
||||
default_value_callback: ''
|
||||
settings: { }
|
||||
field_type: string
|
|
@ -0,0 +1,18 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- block_content
|
||||
- text
|
||||
id: block_content.field_copyright
|
||||
field_name: field_copyright
|
||||
entity_type: block_content
|
||||
type: text_long
|
||||
settings: { }
|
||||
module: text
|
||||
locked: false
|
||||
cardinality: 1
|
||||
translatable: true
|
||||
indexes: { }
|
||||
persist_with_no_fields: false
|
||||
custom_storage: false
|
|
@ -0,0 +1,18 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- block_content
|
||||
- text
|
||||
id: block_content.field_disclaimer
|
||||
field_name: field_disclaimer
|
||||
entity_type: block_content
|
||||
type: text_long
|
||||
settings: { }
|
||||
module: text
|
||||
locked: false
|
||||
cardinality: 1
|
||||
translatable: true
|
||||
indexes: { }
|
||||
persist_with_no_fields: false
|
||||
custom_storage: false
|
|
@ -1,8 +1,13 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
content:
|
||||
- 'block_content:disclaimer_block:9b4dcd67-99f3-48d0-93c9-2c46648b29de'
|
||||
enforced:
|
||||
module:
|
||||
- demo_umami_content
|
||||
module:
|
||||
- demo_umami
|
||||
- block_content
|
||||
theme:
|
||||
- umami
|
||||
id: umami_disclaimer
|
||||
|
@ -10,16 +15,13 @@ theme: umami
|
|||
region: bottom
|
||||
weight: 10
|
||||
provider: null
|
||||
plugin: umami_disclaimer
|
||||
plugin: 'block_content:9b4dcd67-99f3-48d0-93c9-2c46648b29de'
|
||||
settings:
|
||||
id: umami_disclaimer
|
||||
id: 'block_content:9b4dcd67-99f3-48d0-93c9-2c46648b29de'
|
||||
label: 'Umami disclaimer'
|
||||
provider: demo_umami
|
||||
provider: block_content
|
||||
label_display: '0'
|
||||
umami_disclaimer:
|
||||
value: '<strong>Umami Magazine & Umami Publications</strong> is a fictional magazine and publisher for illustrative purposes only.'
|
||||
format: basic_html
|
||||
umami_copyright:
|
||||
value: '© 2018 Terms & Conditions'
|
||||
format: basic_html
|
||||
status: true
|
||||
info: ''
|
||||
view_mode: full
|
||||
visibility: { }
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
content:
|
||||
- 'block_content:footer_promo_block:924ab293-8f5f-45a1-9c7f-2423ae61a241'
|
||||
enforced:
|
||||
module:
|
||||
- demo_umami_content
|
||||
module:
|
||||
- demo_umami
|
||||
- block_content
|
||||
theme:
|
||||
- umami
|
||||
id: umami_footer_promo
|
||||
|
@ -10,14 +15,13 @@ theme: umami
|
|||
region: footer
|
||||
weight: -1
|
||||
provider: null
|
||||
plugin: umami_footer_promo
|
||||
plugin: 'block_content:924ab293-8f5f-45a1-9c7f-2423ae61a241'
|
||||
settings:
|
||||
id: umami_footer_promo
|
||||
label: 'Umami Footer promo'
|
||||
provider: demo_umami
|
||||
id: 'block_content:924ab293-8f5f-45a1-9c7f-2423ae61a241'
|
||||
label: 'Umami footer promo'
|
||||
provider: block_content
|
||||
label_display: '0'
|
||||
promo_title: 'Umami Food Magazine'
|
||||
promo_text: 'Skills and know-how. Magazine exclusive articles, recipes and plenty of reasons to get your copy today.'
|
||||
findmore_url: '/about-umami'
|
||||
findmore_text: 'Find out more'
|
||||
status: true
|
||||
info: ''
|
||||
view_mode: full
|
||||
visibility: { }
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
block.settings.umami_disclaimer:
|
||||
type: block_settings
|
||||
label: 'Disclaimer block'
|
||||
mapping:
|
||||
umami_disclaimer:
|
||||
type: text_format
|
||||
label: 'Disclaimer'
|
||||
umami_copyright:
|
||||
type: text_format
|
||||
label: 'Copyright'
|
||||
|
||||
block.settings.umami_footer_promo:
|
||||
type: block_settings
|
||||
label: 'Footer promo block'
|
||||
mapping:
|
||||
promo_title:
|
||||
type: string
|
||||
label: 'Promo title'
|
||||
promo_text:
|
||||
type: string
|
||||
label: 'Promo text'
|
||||
findmore_url:
|
||||
type: string
|
||||
label: 'Find more URL'
|
||||
findmore_text:
|
||||
type: string
|
||||
label: 'Find more text'
|
|
@ -313,6 +313,38 @@ class InstallHelper implements ContainerInjectionInterface {
|
|||
'alt' => 'Mouth watering vegetarian pasta bake with rich tomato sauce and cheese toppings',
|
||||
],
|
||||
],
|
||||
'umami_disclaimer' => [
|
||||
'uuid' => '9b4dcd67-99f3-48d0-93c9-2c46648b29de',
|
||||
'info' => 'Umami disclaimer',
|
||||
'type' => 'disclaimer_block',
|
||||
'field_disclaimer' => [
|
||||
'value' => '<strong>Umami Magazine & Umami Publications</strong> is a fictional magazine and publisher for illustrative purposes only.',
|
||||
'format' => 'basic_html',
|
||||
],
|
||||
'field_copyright' => [
|
||||
'value' => '© 2018 Terms & Conditions',
|
||||
'format' => 'basic_html',
|
||||
],
|
||||
],
|
||||
'umami_footer_promo' => [
|
||||
'uuid' => '924ab293-8f5f-45a1-9c7f-2423ae61a241',
|
||||
'info' => 'Umami footer promo',
|
||||
'type' => 'footer_promo_block',
|
||||
'field_title' => [
|
||||
'value' => 'Umami Food Magazine',
|
||||
],
|
||||
'field_summary' => [
|
||||
'value' => 'Skills and know-how. Magazine exclusive articles, recipes and plenty of reasons to get your copy today.',
|
||||
],
|
||||
'field_content_link' => [
|
||||
'uri' => 'internal:' . call_user_func(function () {
|
||||
$nodes = $this->entityTypeManager->getStorage('node')->loadByProperties(['title' => 'About Umami']);
|
||||
$node = reset($nodes);
|
||||
return $this->aliasManager->getAliasByPath('/node/' . $node->id());
|
||||
}),
|
||||
'title' => 'Find out more',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Create block content.
|
||||
|
|
|
@ -45,12 +45,15 @@ class UninstallDefaultContentTest extends BrowserTestBase {
|
|||
$node_storage->resetCache();
|
||||
|
||||
// Assert the removal of blocks on uninstall.
|
||||
$count = $block_storage->getQuery()
|
||||
->condition('type', 'banner_block')
|
||||
->count()
|
||||
->execute();
|
||||
$this->assertEquals(0, $count);
|
||||
$this->assertNull($this->container->get('entity_type.manager')->getStorage('block')->load('umami_banner_recipes'));
|
||||
foreach ($this->expectedBlocks() as $block_info) {
|
||||
$count = $block_storage->getQuery()
|
||||
->condition('type', $block_info['type'])
|
||||
->count()
|
||||
->execute();
|
||||
$this->assertEquals(0, $count);
|
||||
$block = $block_storage->loadByProperties(['uuid' => $block_info['uuid']]);
|
||||
$this->assertCount(0, $block);
|
||||
}
|
||||
|
||||
// Assert the removal of nodes on uninstall.
|
||||
$count = $node_storage->getQuery()
|
||||
|
@ -95,20 +98,49 @@ class UninstallDefaultContentTest extends BrowserTestBase {
|
|||
* Block storage.
|
||||
*/
|
||||
protected function assertImportedCustomBlock(EntityStorageInterface $block_storage) {
|
||||
// Verify that block is placed.
|
||||
$assert = $this->assertSession();
|
||||
$this->drupalGet('/recipes');
|
||||
$assert->pageTextContains('Super easy vegetarian pasta bake');
|
||||
$img_alt_text = $assert->elementExists('css', '#block-umami-banner-recipes img')->getAttribute('alt');
|
||||
$this->assertEquals('Mouth watering vegetarian pasta bake with rich tomato sauce and cheese toppings', $img_alt_text);
|
||||
foreach ($this->expectedBlocks() as $block_info) {
|
||||
// Verify that the block is placed.
|
||||
$assert->pageTextContains($block_info['unique_text']);
|
||||
// For the banner block, also verify the presence of alt text on the
|
||||
// banner image.
|
||||
if ($block_info['type'] == 'banner_block') {
|
||||
$img_alt_text = $assert->elementExists('css', '#block-umami-banner-recipes img')->getAttribute('alt');
|
||||
$this->assertEquals('Mouth watering vegetarian pasta bake with rich tomato sauce and cheese toppings', $img_alt_text);
|
||||
}
|
||||
// Verify that the block can be loaded.
|
||||
$count = $block_storage->getQuery()
|
||||
->condition('type', $block_info['type'])
|
||||
->count()
|
||||
->execute();
|
||||
$this->assertGreaterThan(0, $count);
|
||||
$block = $block_storage->loadByProperties(['uuid' => $block_info['uuid']]);
|
||||
$this->assertCount(1, $block);
|
||||
}
|
||||
}
|
||||
|
||||
$count = $block_storage->getQuery()
|
||||
->condition('type', 'banner_block')
|
||||
->count()
|
||||
->execute();
|
||||
$this->assertGreaterThan(0, $count);
|
||||
$block = $block_storage->loadByProperties(['uuid' => '4c7d58a3-a45d-412d-9068-259c57e40541']);
|
||||
$this->assertCount(1, $block);
|
||||
/**
|
||||
* Returns the expected properties of this profile's custom blocks.
|
||||
*/
|
||||
protected function expectedBlocks() {
|
||||
return [
|
||||
[
|
||||
'type' => 'banner_block',
|
||||
'uuid' => '4c7d58a3-a45d-412d-9068-259c57e40541',
|
||||
'unique_text' => 'A wholesome pasta bake is the ultimate comfort food.',
|
||||
],
|
||||
[
|
||||
'type' => 'disclaimer_block',
|
||||
'uuid' => '9b4dcd67-99f3-48d0-93c9-2c46648b29de',
|
||||
'unique_text' => 'is a fictional magazine and publisher for illustrative purposes only',
|
||||
],
|
||||
[
|
||||
'type' => 'footer_promo_block',
|
||||
'uuid' => '924ab293-8f5f-45a1-9c7f-2423ae61a241',
|
||||
'unique_text' => 'Magazine exclusive articles, recipes and plenty of reasons to get your copy today.',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\demo_umami\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Provides a 'Umami disclaimer' block.
|
||||
*
|
||||
* @Block(
|
||||
* id = "umami_disclaimer",
|
||||
* admin_label = @Translation("Umami disclaimer")
|
||||
* )
|
||||
*
|
||||
* @internal
|
||||
* This code is only for use by the Umami demo profile.
|
||||
*/
|
||||
class UmamiDisclaimer extends BlockBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return [
|
||||
'label_display' => FALSE,
|
||||
'umami_disclaimer' => [
|
||||
'value' => '',
|
||||
'format' => '',
|
||||
],
|
||||
'umami_copyright' => [
|
||||
'value' => '',
|
||||
'format' => '',
|
||||
],
|
||||
] + parent::defaultConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build() {
|
||||
$disclaimer_markup = check_markup($this->configuration['umami_disclaimer']['value'], $this->configuration['umami_disclaimer']['format']);
|
||||
$copyright_markup = check_markup($this->configuration['umami_copyright']['value'], $this->configuration['umami_copyright']['format']);
|
||||
|
||||
return [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => '<span class="umami-disclaimer">{{ disclaimer }}</span><span class="umami-copyright">{{ copyright }}</span>',
|
||||
'#context' => [
|
||||
'disclaimer' => $disclaimer_markup,
|
||||
'copyright' => $copyright_markup,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function blockForm($form, FormStateInterface $form_state) {
|
||||
$form = parent::blockForm($form, $form_state);
|
||||
|
||||
$form['umami_disclaimer'] = [
|
||||
'#type' => 'text_format',
|
||||
'#title' => $this->t('Umami Disclaimer'),
|
||||
'#default_value' => $this->configuration['umami_disclaimer']['value'],
|
||||
'#format' => $this->configuration['umami_disclaimer']['format'],
|
||||
];
|
||||
|
||||
$form['umami_copyright'] = [
|
||||
'#type' => 'text_format',
|
||||
'#title' => $this->t('Umami Copyright Text'),
|
||||
'#default_value' => $this->configuration['umami_copyright']['value'],
|
||||
'#format' => $this->configuration['umami_copyright']['format'],
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function blockSubmit($form, FormStateInterface $form_state) {
|
||||
parent::blockSubmit($form, $form_state);
|
||||
|
||||
$this->configuration['umami_disclaimer'] = $form_state->getValue('umami_disclaimer');
|
||||
$this->configuration['umami_copyright'] = $form_state->getValue('umami_copyright');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\demo_umami\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Render\Element\PathElement;
|
||||
|
||||
/**
|
||||
* Provides a 'Promo banner' block for footer.
|
||||
*
|
||||
* @Block(
|
||||
* id = "umami_footer_promo",
|
||||
* admin_label = @Translation("Umami Bundle")
|
||||
* )
|
||||
*
|
||||
* @internal
|
||||
* This code is only for use by the Umami demo profile.
|
||||
*/
|
||||
class UmamiFooterPromo extends BlockBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return [
|
||||
'label_display' => FALSE,
|
||||
'promo_title' => '',
|
||||
'promo_text' => '',
|
||||
'findmore_url' => '',
|
||||
'findmore_text' => '',
|
||||
] + parent::defaultConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build() {
|
||||
return [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => '<h2 class="footer-promo__title">{{ promo_title }}</h2><p class="footer-promo__text">{{ promo_text }} {% if findmore_url %} <a href="{{ findmore_url }}">{{ findmore_text }}</a> {% endif %}</p>',
|
||||
'#context' => [
|
||||
'promo_title' => $this->configuration['promo_title'],
|
||||
'promo_text' => $this->configuration['promo_text'],
|
||||
'findmore_url' => $this->configuration['findmore_url'],
|
||||
'findmore_text' => $this->configuration['findmore_text'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function blockForm($form, FormStateInterface $form_state) {
|
||||
$form = parent::blockForm($form, $form_state);
|
||||
|
||||
$form['promo_title'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Promo Title'),
|
||||
'#default_value' => $this->configuration['promo_title'],
|
||||
];
|
||||
|
||||
$form['promo_text'] = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => $this->t('Promo Text'),
|
||||
'#default_value' => $this->configuration['promo_text'],
|
||||
];
|
||||
|
||||
$form['findmore'] = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => $this->t('Find more'),
|
||||
];
|
||||
|
||||
$form['findmore']['url'] = [
|
||||
'#type' => 'path',
|
||||
'#convert_path' => PathElement::CONVERT_NONE,
|
||||
'#validate_path' => FALSE,
|
||||
'#title' => $this->t('URL'),
|
||||
'#default_value' => $this->configuration['findmore_url'],
|
||||
'#description' => $this->t('Enter an relative or absolute url. Eg: /about-umami or https://www.drupal.org'),
|
||||
];
|
||||
|
||||
$form['findmore']['text'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Text'),
|
||||
'#default_value' => $this->configuration['findmore_text'],
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function blockSubmit($form, FormStateInterface $form_state) {
|
||||
parent::blockSubmit($form, $form_state);
|
||||
|
||||
$this->configuration['promo_title'] = $form_state->getValue('promo_title');
|
||||
$this->configuration['promo_text'] = $form_state->getValue('promo_text');
|
||||
$this->configuration['findmore_url'] = $form_state->getValue(['findmore', 'url']);
|
||||
$this->configuration['findmore_text'] = $form_state->getValue(['findmore', 'text']);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,26 +3,26 @@
|
|||
* This file is used to style the banner block.
|
||||
*/
|
||||
|
||||
.block-banner-block {
|
||||
.block-type-banner-block {
|
||||
background-size: 0 0;
|
||||
}
|
||||
|
||||
.block-banner-block .summary {
|
||||
.block-type-banner-block .summary {
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
.block-banner-block .field--name-field-title {
|
||||
.block-type-banner-block .field--name-field-title {
|
||||
font-family: 'Scope One', Georgia, serif;
|
||||
font-size: 1.424rem;
|
||||
font-weight: 400;
|
||||
margin: 0 0 1.07em 0;
|
||||
}
|
||||
|
||||
.block-banner-block .field--name-field-summary {
|
||||
.block-type-banner-block .field--name-field-summary {
|
||||
margin-bottom: 1.28em;
|
||||
}
|
||||
|
||||
.block-banner-block .field--name-field-content-link a {
|
||||
.block-type-banner-block .field--name-field-content-link a {
|
||||
display: inline-block;
|
||||
padding: 0.5em 1.5em 0.4em;
|
||||
border: 0;
|
||||
|
@ -39,8 +39,8 @@
|
|||
transition: background-color 0.5s ease;
|
||||
}
|
||||
|
||||
.block-banner-block .field--name-field-content-link a:focus,
|
||||
.block-banner-block .field--name-field-content-link a:hover {
|
||||
.block-type-banner-block .field--name-field-content-link a:focus,
|
||||
.block-type-banner-block .field--name-field-content-link a:hover {
|
||||
background-color: #00836d;
|
||||
color: #fff;
|
||||
text-decoration: underline;
|
||||
|
@ -48,7 +48,7 @@
|
|||
|
||||
/* 768px */
|
||||
@media screen and (min-width: 48rem) { /* 768px */
|
||||
.block-banner-block {
|
||||
.block-type-banner-block {
|
||||
background-color: #464646;
|
||||
background-size: cover;
|
||||
background-position: left center;
|
||||
|
@ -56,7 +56,7 @@
|
|||
/* Image ratio 7:3 */
|
||||
}
|
||||
|
||||
.block-banner-block .block-inner {
|
||||
.block-type-banner-block .block-inner {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
|
@ -65,13 +65,13 @@
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
.block-banner-block .summary {
|
||||
.block-type-banner-block .summary {
|
||||
margin: 0;
|
||||
flex: 0 0 30%;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.block-banner-block .field--name-field-banner-image {
|
||||
.block-type-banner-block .field--name-field-banner-image {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* @file
|
||||
* This file is used to style the disclaimer block.
|
||||
*/
|
||||
|
||||
.block-type-disclaimer-block .field--name-field-disclaimer,
|
||||
.block-type-disclaimer-block .field--name-field-copyright {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 0.94rem;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 75rem) {
|
||||
.block-type-disclaimer-block .field--name-field-disclaimer,
|
||||
.block-type-disclaimer-block .field--name-field-copyright {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.block-type-disclaimer-block .field--name-field-disclaimer {
|
||||
float: left;
|
||||
max-width: 40%;
|
||||
text-align: left;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.block-type-disclaimer-block .field--name-field-copyright {
|
||||
float: right;
|
||||
width: 25%;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
|
@ -3,17 +3,21 @@
|
|||
* This file is used to style the Footer promo block.
|
||||
*/
|
||||
|
||||
.footer-promo {
|
||||
.block-type-footer-promo-block {
|
||||
padding-top: 250px;
|
||||
background: url('../../../../images/png/umami-bundle.png') no-repeat center top;
|
||||
}
|
||||
|
||||
.footer-promo__title {
|
||||
.block-type-footer-promo-block .block__title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.footer-promo__text a {
|
||||
.block-type-footer-promo-block .footer-promo-content {
|
||||
margin-bottom: 1.28rem;
|
||||
}
|
||||
|
||||
.block-type-footer-promo-block .footer-promo-content a {
|
||||
background-color: inherit;
|
||||
clear: left;
|
||||
display: block;
|
||||
|
@ -22,14 +26,14 @@
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
.footer-promo__text a:active,
|
||||
.footer-promo__text a:focus,
|
||||
.footer-promo__text a:hover {
|
||||
.block-type-footer-promo-block .footer-promo-content a:active,
|
||||
.block-type-footer-promo-block .footer-promo-content a:focus,
|
||||
.block-type-footer-promo-block .footer-promo-content a:hover {
|
||||
background-color: transparent;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.footer-promo__text a:after {
|
||||
.block-type-footer-promo-block .footer-promo-content a:after {
|
||||
display: inline-block;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
|
@ -39,7 +43,7 @@
|
|||
}
|
||||
|
||||
@media screen and (min-width: 60rem) {
|
||||
.footer-promo {
|
||||
.block-type-footer-promo-block {
|
||||
flex-basis: 60%;
|
||||
height: 200px;
|
||||
padding-top: 0;
|
||||
|
@ -48,7 +52,7 @@
|
|||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.footer-promo__title {
|
||||
.block-type-footer-promo-block .block__title {
|
||||
padding-top: 2rem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,34 +9,8 @@
|
|||
overflow: hidden;
|
||||
}
|
||||
|
||||
.umami-disclaimer,
|
||||
.umami-copyright {
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 0.94rem;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 75rem) {
|
||||
.layout-bottom {
|
||||
padding: 3rem 0;
|
||||
}
|
||||
|
||||
.umami-disclaimer,
|
||||
.umami-copyright {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.umami-disclaimer {
|
||||
float: left;
|
||||
max-width: 40%;
|
||||
text-align: left;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.umami-copyright {
|
||||
float: right;
|
||||
width: 25%;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
'block',
|
||||
'block-' ~ configuration.provider|clean_class,
|
||||
'block-' ~ plugin_id|clean_class,
|
||||
'block-banner-block',
|
||||
'cover-image',
|
||||
]
|
||||
%}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Theme override to display a block.
|
||||
*
|
||||
* Available variables:
|
||||
* - plugin_id: The ID of the block implementation.
|
||||
* - label: The configured label of the block if visible.
|
||||
* - configuration: A list of the block's configuration values.
|
||||
* - label: The configured label for the block.
|
||||
* - label_display: The display settings for the label.
|
||||
* - provider: The module or other provider that provided this block plugin.
|
||||
* - Block plugin specific settings will also be stored here.
|
||||
* - content: The content of this block.
|
||||
* - attributes: array of HTML attributes populated by modules, intended to
|
||||
* be added to the main container tag of this template.
|
||||
* - id: A valid HTML ID and guaranteed unique.
|
||||
* - title_attributes: Same as attributes, except applied to the main title
|
||||
* tag that appears in the template.
|
||||
* - title_prefix: Additional output populated by modules, intended to be
|
||||
* displayed in front of the main title tag that appears in the template.
|
||||
* - title_suffix: Additional output populated by modules, intended to be
|
||||
* displayed after the main title tag that appears in the template.
|
||||
*
|
||||
* @see template_preprocess_block()
|
||||
*/
|
||||
#}
|
||||
<div{{ attributes }}>
|
||||
{{ title_prefix }}
|
||||
{% if label %}
|
||||
<h2{{ title_attributes }}>{{ label }}</h2>
|
||||
{% elseif content.field_title %}
|
||||
<h2{{ title_attributes }}>{{ content.field_title }}</h2>
|
||||
{% endif %}
|
||||
{{ title_suffix }}
|
||||
{% block content %}
|
||||
<div class="footer-promo-content">
|
||||
{% if not label %}
|
||||
{{ content|without('field_title') }}
|
||||
{% else %}
|
||||
{{ content }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
</div>
|
|
@ -1,8 +0,0 @@
|
|||
{% extends "block.html.twig" %}
|
||||
{#
|
||||
/**
|
||||
* @file
|
||||
* Theme override for Umami footer Promo block.
|
||||
*/
|
||||
#}
|
||||
{% set attributes = attributes.addClass('footer-promo') %}
|
|
@ -5,6 +5,7 @@ global:
|
|||
css/base.css: {}
|
||||
css/components/blocks/banner/banner.css: {}
|
||||
css/components/blocks/branding/branding.css: {}
|
||||
css/components/blocks/disclaimer/disclaimer.css: {}
|
||||
css/components/blocks/page-title/page-title.css: {}
|
||||
css/components/blocks/footer-promo/footer-promo.css: {}
|
||||
css/components/blocks/search/search.css: {}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* Functions to support theming in the Umami theme.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
|
||||
|
@ -45,6 +46,10 @@ function umami_preprocess_field(&$variables, $hook) {
|
|||
*/
|
||||
function umami_preprocess_block(&$variables) {
|
||||
$variables['title_attributes']['class'][] = 'block__title';
|
||||
// Add a class indicating the custom block bundle.
|
||||
if (isset($variables['elements']['content']['#block_content'])) {
|
||||
$variables['attributes']['class'][] = Html::getClass('block-type-' . $variables['elements']['content']['#block_content']->bundle());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue