Configuration Views
Enables site builders to create Views based on configuration entities, such as roles, menus, image styles, and content types.
config_views
インストール
composer require 'drupal/config_views:^2.1'
概要
Configuration ViewsはDrupalのViewsモジュールを拡張し、設定エンティティをデータソースとしてサポートします。これにより、サイトビルダーはコンテンツタイプ、メニュー、画像スタイル、タクソノミーボキャブラリ、ユーザーロール、およびDrupalの他のほぼすべての設定エンティティのカスタマイズされたリストを作成できます。
このモジュールは、DrupalのEntity Query APIを活用して設定エンティティを取得するカスタムクエリプラグインと、文字列およびブーリアンフィールド用の専用フィルターハンドラーを提供します。また、エンティティの操作(編集、削除など)を表示するフィールドハンドラーと、設定エンティティをターゲットとするエンティティ参照フィールドのソースとしてViewsを使用できるEntity Reference Selectionプラグインも含まれています。
インストール時に、標準のDrupal管理リストページを置き換える14の事前設定されたViewsが提供されます。これらのViewsはカスタマイズ、公開フィルターの追加、ソート、ページネーション、さまざまな形式へのエクスポートが可能で、Viewsの全機能を設定管理インターフェースにもたらします。
Features
- DrupalのEntity Query APIを使用して設定エンティティをクエリできるカスタムViewsクエリプラグイン(views_config_entity_query)
- 文字列フィルタープラグイン(config_entity_string):等しい、等しくない、含む、で始まる、で終わる、空である、空でないの演算子をサポート
- 設定エンティティのブーリアンフィールドをフィルタリングするためのブーリアンフィルタープラグイン(config_entity_boolean)
- エンティティ操作リンク(編集、削除など)をレンダリングする操作フィールドプラグイン(config_entity_operations)
- Viewsを使用して設定エンティティ参照をフィルタリングできるEntity Reference Selectionプラグイン(config_views)
- コアの管理ページを置き換える14の事前構築されたViews:コメントタイプ、コンタクトフォーム、コンテンツタイプ、カスタムブロックタイプ、日付形式、フォームモード、画像スタイル、メニュー、ショートカット、タクソノミーボキャブラリ、テキストフォーマット、ユーザーロール、ビューモード、Viewsリスト
- Viewsウィザードの自動カテゴリ分け:Add Viewフォームで設定エンティティViewsを「Configuration」の下にグループ化
- 公開フィルター、ソート、ページング、さまざまな表示形式を含む完全なViews機能のサポート
- コンテンツと設定オプションをアルファベット順にグループ化してビューウィザードを整理するHook実装
Use Cases
Creating a filtered list of content types
Site builders can customize the Content types view to add exposed filters, allowing administrators to search for specific content types by name or filter by properties like whether they have a description. The view can be sorted by any available field.
Building a role-based entity reference field
Using the config_views Entity Reference Selection handler, developers can create an entity reference field that references user roles, filtered by a View. For example, a field could reference only roles that have a specific permission or match certain criteria defined in the View's filters.
Customizing admin pages with Views features
Replace standard Drupal admin listing pages with Views-powered versions that support pagination, exposed search filters, sortable columns, and the ability to export lists (with appropriate export modules like Views Data Export).
Creating a dashboard of all enabled Views
Enable the views_list View to get a customizable list of all Views on the site. The View shows enabled and disabled views separately and can be customized to add filters by tag, show only views with specific displays, etc.
Managing image styles with search
Customize the image_styles View to add an exposed filter on the style name, making it easier to find specific image styles on sites with many style definitions.
Tips
- Some Views are disabled by default. Review them at /admin/structure/views and enable the ones you want to use.
- The module automatically makes all configuration entity types available as Views base tables - not just the 14 pre-built Views.
- When creating a new View, look under the 'Configuration' group in the 'Show' dropdown to find all available configuration entity types.
- The config_views Entity Reference Selection handler is useful when you need to reference configuration entities (like roles) from entity reference fields and want Views filtering capabilities.
- All standard Views features work with configuration entity Views: exposed filters, sorts, pagers, different display types, relationships, and more.
Technical Details
Admin Pages 14
/admin/structure/comment
Lists all comment types defined on the site. Displays comment type label, description, and provides operation links for editing and managing each comment type. Replaces the core comment types admin page.
/admin/structure/contact
Lists all contact forms. Displays form label, recipients (reply field), and operation links. This View is disabled by default.
/admin/structure/types
Lists all content types with their names, descriptions, and operation links. Provides a Views-based replacement for the core content types admin page with full pagination support.
/admin/structure/block/block-content/types
Lists all custom block types with labels linked to their edit pages, descriptions, and operation links.
/admin/config/regional/date-time
Lists all date format configurations showing the format name, pattern, and operation links.
/admin/structure/display-modes/form
Lists all entity form modes grouped by target entity type. Shows the form mode name and operations. This View is disabled by default.
/admin/config/media/image-styles
Lists all image styles showing the style name and operation links for editing, flushing, and deleting styles.
/admin/structure/menu
Lists all menus with their names (displayed in bold), descriptions, and operation links. Sorted alphabetically by label.
/admin/config/user-interface/shortcut
Lists all shortcut sets with their names and operation links.
/admin/structure/taxonomy
Lists all taxonomy vocabularies sorted alphabetically by name, with operation links for managing terms and vocabulary settings.
/admin/config/content/formats
Lists all text formats/filter formats with their names and operation links. This View is disabled by default.
/admin/people/roles
Lists all user roles sorted by weight, showing role labels and operation links. This View is disabled by default.
/admin/structure/display-modes/view
Lists all entity view modes grouped by target entity type. Shows the view mode name and operations. This View is disabled by default.
/admin/structure/views
Lists all Views separated into Enabled and Disabled sections. Shows view name (as h3 heading), description, tag, and operations. The disabled views appear in a footer block. This View is disabled by default.
Hooks 2
hook_views_data
Implements hook_views_data() to register all configuration entity types as Views base tables. Dynamically discovers all configuration entities and creates Views data definitions including fields, filters, sorts, and arguments based on the entity's config schema.
hook_form_FORM_ID_alter
Implements hook_form_view_add_form_alter() to reorganize the Views wizard selection dropdown, grouping configuration entity types under a 'Configuration' optgroup and content types under 'Content', with alphabetical sorting within each group.
Troubleshooting 4
Several Views are disabled by default because they may not perfectly replicate core's admin page design. Enable them at /admin/structure/views only after reviewing that they meet your needs. You can then customize them to match your requirements.
The module currently provides limited fields (name, description, id, etc.). Getting entity-specific fields for all configuration entity types is a work in progress. Use available fields from the config schema or create custom field handlers.
Views for managing fields (field_config entities) are not yet implemented. This is a known limitation.
Configuration entity queries use a different pagination mechanism than SQL queries. Ensure you're using a compatible pager type (full pager or mini pager work correctly).
Security Notes 2
- Each pre-configured View respects core permission requirements (e.g., 'administer content types', 'administer permissions'). Access control is configured on each View.
- When customizing Views or creating new ones based on configuration entities, ensure appropriate access restrictions are configured to prevent unauthorized access to configuration data.