Field as Block
Allows displaying individual fields from content entities as independent blocks that can be placed in any region of your theme.
fieldblock
インストール
composer require 'drupal/fieldblock:8.x-2.3'
composer require 'drupal/fieldblock:8.x-2.2'
概要
Field as Blockモジュールは、現在のEntity(Node、ユーザー、Taxonomy Termなど)の任意のFieldを個別のBlockとして表示する機能を提供します。これは、Fieldの表示をメインコンテンツエリアから分離し、特定のFieldをページレイアウトの異なるリージョンに配置したい場合に特に便利です。
すべてのFieldがEntityビュー内で一緒にレンダリングされるのではなく、このモジュールは有効化された各Entityタイプに対して派生Blockプラグインを作成します。これにより、サイトビルダーは特定のFieldとそのフォーマッターを選択し、標準のBlockレイアウトシステムを使用してそのFieldの出力をページ上の任意の場所に配置できます。
モジュールはルートから表示中の現在のEntityを自動的に検出し、設定されたフォーマッターで選択したFieldをレンダリングします。適切なキャッシュ処理、翻訳サポート、アクセス制御が含まれており、Fieldが適切な場合にのみ表示されることを保証します。
Features
- コンテンツEntityのあらゆるFieldからBlockを作成(Node、ユーザー、Taxonomy Term、その他のコンテンツEntityタイプ)
- 管理設定を通じてField Blockを利用可能にするEntityタイプを選択
- 選択したEntityタイプから任意の利用可能なFieldを選択してBlockとして表示
- Block設定でFieldフォーマッターとその設定を直接構成
- Fieldのラベルを自動的にBlockタイトルとして使用するオプション
- ルートコンテキストからの現在のEntityの自動検出
- 表示されるEntityに紐づいた適切なキャッシュ無効化
- 完全な翻訳サポート - 現在の言語でField値を表示
- Fieldアクセス権限と空のFieldステータスの両方をチェックするアクセス制御
- Entityタイプが無効化された際の孤立したField Blockを削除するクリーンアップユーティリティ
- ベースFieldと設定可能なFieldの両方で動作
Use Cases
Display author information in sidebar
Create a User field block to display the author's profile picture or bio in a sidebar region on node pages, separate from the main content area.
Featured image in header region
Use a Content field block to display the node's featured image field in a header region above the main content, creating a hero image effect.
Taxonomy tags in footer
Place a Content field block configured to show the Tags field in a footer region, separating the taxonomy display from the main article body.
Custom field layouts without Layout Builder
For sites not using Layout Builder, Field as Block provides a way to break apart the entity display and place individual fields in different theme regions using standard block placement.
Reuse field display across entity types
When multiple entity types share a field (e.g., a 'Summary' field on both nodes and taxonomy terms), you can place field blocks for each type in the same region with appropriate visibility conditions.
Tips
- Enable only the entity types you actually need to reduce clutter in the block library
- Use the 'Use field label as block title' option to automatically generate meaningful block titles
- Remember that field blocks are cached per route, so they automatically update when viewing different entities
- Consider block visibility settings to show field blocks only on appropriate pages
- Field blocks work with both base fields (like title, created date) and configurable fields (like custom text fields)
Technical Details
Admin Pages 1
/admin/config/fieldblock/fieldblockconfig
Configure which entity types should have their fields available as blocks, and clean up orphaned field blocks from entity types that have been disabled or removed.
権限 1
Troubleshooting 5
The block only displays when: 1) The current page is viewing an entity of the configured type, 2) The entity has the configured field, 3) The field is not empty, and 4) The current user has permission to view the field. Check all these conditions.
Navigate to Administration > Configuration > System > Field as Block settings and enable your custom entity type. Only content entity types (not configuration entities) are compatible.
Use the cleanup section on the Field as Block settings page to remove blocks that belong to disabled or removed entity types.
The module includes translation support and should display the field in the current language. Ensure your entity has a translation for the current language.
Ensure you click 'Save block' after changing formatter settings. The formatter settings form uses AJAX to update when you change the field or formatter selection.
Security Notes 3
- The module respects Drupal's field access system - fields are only displayed if the current user has view permission
- Empty fields are automatically hidden, preventing display of placeholder content
- The 'administer fieldblock' permission should be granted only to trusted administrators as it controls which entity types expose their fields