A compositional framework for playing with entities and render arrays.
Required for Entity display plugin (an alternative to entity view modes), List format, Cfr block, and possibly more in the future.
The classes and interfaces provided by renderkit can be used standalone, or as cfr plugins, e.g. with entdisp.
Screencast: https://www.youtube.com/watch?v=AejsIbZO2MI
Built-in components
Here is an incomplete list of what is possible with built-in renderkit components.
Entity display:
- Show a field with a formatter, plus optional field display processor.
- Show the entity title
- Show a sequence of entity displays, with a list format.
- Image from an EntityImage component, with an image processor (e.g. an image style).
- Conditional entity displays with if/else logic.
- Display a single related entity
- Display a list of related entities, using a list format.
- Chain of responsibility: Try a list of entity displays, stop at the first one that returns something non-empty.
- Show a views display (from views module) with the entity id as argument (contextual filter value).
- Show a list of images (e.g. from a multiple-value image field) with an images formatter (e.g. for a picture gallery).
Entity condition:
- Entity conditions based on field values, published status, etc.
List format:
- Display items as ul/li list with custom class name.
- Display items with a separator.
- Wrap each list item into a container.
Entity build processor:
- Wrap an entity display into a link container.
- Wrap an entity display into a container with custom tag name and custom class.
- Wrap an entity display into a container with contextual links.
- Wrap an entity display into a container with CSS background image based on an entity image provider.
Entity image provider:
- Image from image field.
- Image from user picture.
- Image from related entity.
Entity-to-entity:
- Entity from entityreference field.
- Entity author
Build provider:
- Show block content.
- Show a views display (from views module)
- Show a views exposed form (from views module)
- Show a sequence of build providers + list format.
Field display processor:
- Use a list format for the field items.
Userland component examples
In your own custom modules, you can define your own components and component types, with almost no limitations!
On existing websites, this system has been used for:
- Picture galleries with combination of e.g. photoswipe + carousel
- Conditional images display, where a single image is displayed as a static image + zoom, but multiple images are displayed as an interactive gallery.
- Containers with expand/collapse buttons.
- Tabs with custom labels, where each tab has its own entity display.
- Grid list formats (flex, inline-block or float).
- Custom reusable link wrappers with fancy shadows or hover effects.
- Layouts with regions, where each region is filled with an entity display.
- Fallback logic to consider multiple fields and properties until a value is found.
- Conditional displays.
- Social icons.
- Showing node comments inside a collapse/expand box.
- Entity display inside a popup, where the button is within another entity display.
- Showing fields from a related entity alongside fields of the source entity.
- Showing field items in a carousel.
- In combination with paragraphs.
- As a UI for EntityFieldQuery, replacing views for some use cases (in combination with entity display and list format components).
Integration with existing Drupal subsystems
(an incomplete list)
Entity displays can be used via EntDisP and EntDisP Field UI module
- as views row plugin
- as views field handler
- as field formatter for entity reference, taxonomy term reference, paragraphs etc.
- as entry inside an entity view mode (similar to display suite custom fields).
- inside other renderkit components.
List formats can be used
- as views style plugins using Listformat module.
- inside other renderkit components.
Build providers can be used
- as blocks via Cfr block.
- inside other renderkit components
Custom module architecture patterns
A good strategy is to create a custom module e.g. "mysite_components" with:
- Custom theme hooks / templates accompanied by CSS files, with dedicated CSS classes.
- Custom hook_element_info() element types.
- PHP classes that integrate these components with renderkit, in a PSR-4 file organization similar to what you find in renderkit itself.
- Don't forget to implement hook_cfrplugin_info() similar as renderkit does it.
- Don't hardcode any node types / bundles, view names or field names in the custom module! Instead, make these configurable, so that your components are reusable for other field names, node types etc.
Then, as a site builder:
- Enable cfr:cfrplugin, cfr:cfrplugindiscovery, cfrpreset and other cfr-related modules.
- Configure presets for entity displays, build providers, list formats etc.
- Export these presets into a feature module, e.g. mysite_ft_cfrpreset.
Installation: Standalone
If you want to use only renderkit without any plugin integration, simply install like any regular Drupal 7 module.
Installation: With cfrplugin, entdisp and others.
You find instructions here:
https://www.drupal.org/project/cfr
and here:
https://github.com/donquixote/d7-cfr-recommended/blob/master/README.md
Drupal 8?
Working on it.
Project information
- Project categories: Content display
2 sites report using this module
- Created by donquixote on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
