Micro-content
microcontent
Provides a lightweight, reusable content entity type with bundle support for creating small, field-enabled content snippets that support revisions and translations.
Overview
Micro-content is a Drupal module that provides a lightweight, reusable content entity type designed for creating small pieces of structured content. Unlike full nodes, micro-content entities are intended for smaller, reusable content snippets such as testimonials, person cards, ratings, or career outcomes.
The module provides a bundle system (micro-content types) that allows site builders to define different types of micro-content with their own field configurations. Each micro-content type can have a description and a CSS class to help content editors visually distinguish between types in the admin interface.
Key capabilities include full revision support with revision logging, translation support for multilingual sites, entity ownership tracking, publish/unpublish workflow, and integration with Drupal's content moderation system when enabled. The module also provides Views integration for creating custom listings and an Entity Browser integration for selecting micro-content in entity reference fields.
Install
composer require 'drupal/microcontent:^2.0'
composer require 'drupal/microcontent:8.x-1.8'
Features
- Custom content entity type (microcontent) with configurable bundle types (microcontent_type)
- Full revision support with revision user, timestamp, and log message tracking
- Translation support for multilingual content management
- Entity ownership tracking with author information
- Publish/unpublish workflow with status field
- Content Moderation integration - enforces revisions when moderation is enabled
- Views integration with custom views data for building admin listings and frontends
- Entity Browser integration with modal display for selecting existing or creating new micro-content
- JSON API support with filter access for published/unpublished content
- Contextual links support for quick editing from rendered output
- Field UI integration for adding custom fields to micro-content types
- Bundle-based permission granularity for fine-grained access control
- CSS type class support for admin theme customization to distinguish content types visually
- Preview view mode for displaying micro-content in admin contexts
Use Cases
Testimonials and Quotes
Create a 'Testimonial' micro-content type with fields for quote text, author name, author title, company, and photo. Use this to manage client testimonials that can be referenced from multiple pages without duplicating content.
Person Cards
Create a 'Person Card' micro-content type for staff or team member profiles with fields for photo, name, title, bio, and contact information. Reference these cards in team pages, article author bios, or event speaker listings.
Ratings and Reviews
Create a 'Rating' micro-content type with fields for rating value, review text, reviewer name, and date. Use for product reviews, course ratings, or service feedback that can be displayed in multiple contexts.
Call-to-Action Blocks
Create a 'CTA' micro-content type with headline, description, button text, and link fields. Allows content editors to create reusable call-to-action components that can be placed in various page layouts.
Feature Highlights
Create a 'Feature' micro-content type with icon, title, and description fields for highlighting product or service features. Reference these in landing pages, comparison tables, or feature matrices.
FAQ Items
Create a 'FAQ' micro-content type with question and answer fields. Manage FAQ content centrally and reference it in multiple FAQ pages or contextually relevant content areas.
Tips
- Use the Type class field when creating micro-content types to add CSS classes that help visually distinguish different types in the admin interface
- Consider enabling 'Create new revision' by default for types where you want to track content history
- Use the preview view mode to customize how micro-content appears in admin listings and entity browsers
- When using Entity Browser, the module provides a ready-to-use browser configuration with both selection and inline creation capabilities
- Micro-content types support all standard Drupal field types, so you can create complex structured content with images, formatted text, entity references, and more
- The module integrates with JSON API for headless/decoupled architectures - micro-content can be exposed as API resources
Dependencies
Related Projects
Provides optional Entity Browser configuration for selecting micro-content in modal dialogs. Includes a Views-based browser display with preview rendering and an entity form widget for creating new micro-content inline. Configuration is installed when Entity Browser module is enabled.
Full Views integration with custom views data. Provides an admin view (micro_content_admin) for the content overview page and a browser view (microcontent_browser) for entity browser selection. Custom filters for username and bundle selection.
When Content Moderation is enabled, micro-content can be added to moderation workflows. The module provides a custom moderation handler that enforces revision creation when moderation is active.
Provides filter access control for JSON API queries. Users with 'view unpublished microcontent' permission can filter all micro-content, while users with 'access content' can filter published micro-content only.
Optional integration with the backfill_formatter module via the MicroContentHandler plugin. Provides permission-based access control for backfilling micro-content entity references.
Each micro-content type provides Field UI integration for adding custom fields, managing form displays, and managing view displays.
Rendered micro-content includes contextual links for quick editing when users have appropriate permissions.
Admin Pages
| Title | Path | Description |
|---|---|---|
| Micro-content types | /admin/structure/microcontent-types |
Lists all micro-content types. From this page you can add new types, edit existing types, manage fields, configure form and display settings, and delete types. |
| Add micro-content type | /admin/structure/microcontent-types/add |
Form for creating a new micro-content type with label, machine name, description, type class for styling, and revision settings. |
| Edit micro-content type | /admin/structure/microcontent-types/manage/{microcontent_type} |
Form for editing an existing micro-content type's settings including label, description, type class, and revision behavior. |
| Micro-content | /admin/content/microcontent |
Administrative listing of all micro-content entities. Shows preview, type, author, status, updated date, and operations. Supports filtering by label, type, author, and publication status. |
| Add micro-content | /admin/content/microcontent/add |
Selection page showing available micro-content types. Click on a type to create new micro-content of that type. |
| Add micro-content | /admin/content/microcontent/add/{microcontent_type} |
Form for creating a new micro-content entity of the specified type. Form fields depend on the fields configured for the micro-content type. |
| Edit micro-content | /admin/content/microcontent/{microcontent}/edit |
Form for editing an existing micro-content entity. The canonical URL redirects to the edit form since micro-content is admin-only content. |
| Delete micro-content | /admin/content/microcontent/{microcontent}/delete |
Confirmation form for deleting a micro-content entity. This action cannot be undone. |
Permissions
| Permission | Description |
|---|---|
|
Add, update and delete micro-content types. This is a restricted permission. |
|
Full administrative access to all micro-content regardless of type or ownership. This is a restricted permission. |
|
View micro-content that has not been published. |
|
View the micro-content overview page at /admin/content/microcontent. |
|
Create new micro-content of the specified type. Dynamically generated per micro-content type. |
|
Edit micro-content of the specified type that the user owns. Dynamically generated per micro-content type. |
|
Edit any micro-content of the specified type regardless of ownership. Dynamically generated per micro-content type. |
|
Delete micro-content of the specified type that the user owns. Dynamically generated per micro-content type. |
|
Delete any micro-content of the specified type regardless of ownership. Dynamically generated per micro-content type. |
Hooks
| Hook | Description |
|---|---|
hook_preprocess_microcontent |
Prepares variables for microcontent templates. Sets up the microcontent entity, view_mode, name (label), and content variables for theming. |
hook_jsonapi_microcontent_filter_access |
Controls JSON API filter access for microcontent entities. Allows filtering among all entities if user has 'view unpublished microcontent' permission, or among published entities if user has 'access content' permission. |
Troubleshooting
You must create at least one micro-content type before creating content. Go to Administration > Structure > Micro-content types and click 'Add micro-content type'.
Ensure you have the 'access microcontent overview' permission. This permission is separate from content creation/editing permissions.
Ensure the Entity Browser module is installed and enabled. The Entity Browser configuration is only installed when the module is available.
Check the micro-content type settings to ensure 'Create new revision' is enabled. If using Content Moderation, revisions are automatically enforced.
Ensure you have either 'view unpublished microcontent' permission (for all content) or 'access content' permission (for published content only).
Security Notes
- The 'administer microcontent types' and 'administer microcontent' permissions are marked as restricted - only grant to trusted administrators
- Bundle-based permissions allow granular control over who can create, edit, and delete specific types of micro-content
- View access to unpublished micro-content requires explicit 'view unpublished microcontent' permission
- Consider using Content Moderation workflows for micro-content that requires editorial review before publication