Last active
November 14, 2018 09:32
-
-
Save radheymkumar/4bb0a10f95ad1372460e7437bdcbb0ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create block type | |
Field - Title, body, image, link, | |
help - https://medium.com/@sarahcodes/custom-block-type-for-hero-banners-in-drupal-8-7d0adb665fd3 | |
Twig Field value - https://blog.usejournal.com/getting-drupal-8-field-values-in-twig-22b80cb609bd | |
**************************************************** | |
1. themename.theme | |
/** | |
* Implements hook_theme_suggestions_HOOK_alter() for form templates. | |
*/ | |
function bartik_theme_suggestions_form_alter(array &$suggestions, array $variables) { | |
// Block suggestions for custom block bundles. | |
if (isset($variables['elements']['content']['#block_content'])) { | |
array_splice($suggestions, 1, 0, 'block__bundle__' . $variables['elements']['content']['#block_content']->bundle()); | |
} | |
} | |
*************************************************** | |
2. template name - block--whatwellbemaking.html.twig | |
<div class="jumbotron jumbotron-fluid" style="background-image: url({{ file_url(content.field_image['#items'].entity.uri.value) }}); background-size: cover; background-position: center" > | |
<div class="container"> | |
<div class="row"> | |
<div class="col-6"> | |
{{ title_prefix }} | |
{% if label %} | |
<h2{{ title_attributes.addClass('display-4') }}>{{ label }}</h2> | |
{% endif %} | |
{{ title_suffix }} | |
<div class="lead">{{ content.body }}</div> | |
<div><a href="{{ content.field_button[0]['#url'] }}" class="btn btn-primary">{{ content.field_button[0]['#title'] }}</a></div> | |
</div> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment