Skip to content

Commit

Permalink
Block content templates
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Apr 12, 2024
1 parent 430ac5a commit 8275595
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 124 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@
"composer/installers": "^1.7",
"cure53/dompurify": "^3.0",
"cweagans/composer-patches": "^1.7",
"drupal/advanced_text_formatter": "^3.0",
"drupal/allowed_formats": "^3.0",
"drupal/better_exposed_filters": "^6.0",
"drupal/better_social_sharing_buttons": "^4.0",
"drupal/block_content_suggestions": "^1.0",
"drupal/captcha": "^2.0",
"drupal/color_field": "^3.0",
"drupal/config_ignore": "^3.2",
Expand Down
94 changes: 45 additions & 49 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ dependencies:
- field.field.block_content.aside_contact_info.field_image
- field.field.block_content.aside_contact_info.field_phone_number
- field.field.block_content.aside_contact_info.field_title
module:
- advanced_text_formatter
id: block_content.aside_contact_info.default
targetEntityType: block_content
bundle: aside_contact_info
mode: default
content:
field_address:
type: advanced_text
type: string
label: hidden
settings:
link_to_entity: false
trim_length: '0'
ellipsis: '1'
word_boundary: '1'
Expand All @@ -30,7 +29,6 @@ content:
autop: '1'
use_summary: 0
token_replace: 0
link_to_entity: 0
third_party_settings: { }
weight: 3
region: content
Expand Down
2 changes: 1 addition & 1 deletion config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ _core:
langcode: da
module:
aarhus_hero: 0
advanced_text_formatter: 0
advancedqueue: 0
allowed_formats: 0
better_exposed_filters: 0
better_social_sharing_buttons: 0
block: 0
block_content: 0
block_content_suggestions: 0
breakpoint: 0
captcha: 0
ckeditor5: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{#
/**
* @file
* Default theme implementation to display a custom block.
*
* Available variables:
* - block_content: Full custom block entity.
* Only method names starting with "get", "has", or "is" and a few common
* methods such as "id", "label", and "bundle" are available. For example:
* - block_content.getCreatedTime() will return the custom block creation timestamp.
* - block_content.id(): The custom block ID.
* - block_content.bundle(): The type of the custom block, for example, "image" or "text".
* See Drupal\block_content\Entity\BlockContent for a full list of public properties
* and methods for the custom block object.
* - content: All custom block items. Use {{ content }} to print them all,
* or print a subset such as {{ content.field_example }}. Use
* {{ content|without('field_example') }} to temporarily suppress the printing
* of a given child element.
* - attributes: HTML attributes for the containing element.
* - view_mode: View mode; for example, "preview" or "full".
* - logged_in: Flag for authenticated user status. Will be true when the
* current user is a logged-in member.
* - is_admin: Flag for admin user status. Will be true when the current user
* is an administrator.
*
* @see template_preprocess_block_content()
*
* @ingroup themeable
*/
#}

<div class="aside-contact-info">
{% if block_content.field_department.value %}
<div class="text-primary">
{{ block_content.field_department.value }}
</div>
{% endif %}
{% if block_content.field_title.value %}
<div class="h4">
{{ block_content.field_title.value }}
</div>
{% endif %}
{% if block_content.field_address.value %}
<div>
{# @TODO Which is better; `nl2br` or `style="white-space: pre-line"` #}
{{ block_content.field_address.value|nl2br }}
</div>
{% endif %}
{% if block_content.field_phone_number.value %}
<div>
{{ 'Phone'|trans }}: <a href="tel:{{ block_content.field_phone_number.value }}">{{ block_content.field_phone_number.value }}</a>
</div>
{% endif %}
{% if block_content.field_email.value %}
<div>
{{ 'Email'|trans }}: <a href="mailto:{{ block_content.field_email.value }}">{{ block_content.field_email.value }}</a>
</div>
{% endif %}
</div>

This file was deleted.

0 comments on commit 8275595

Please sign in to comment.