Drupal Drupal 4 — Questions and Answers
Question 1: In Drupal, what is the 'Entity API' primarily used for?
- Creating, loading, saving, and deleting entities like nodes, users, and custom types (Correct answer)
- Connecting Drupal to external REST APIs
- Managing database table schemas
- Handling HTTP requests and responses
Correct answer: Creating, loading, saving, and deleting entities like nodes, users, and custom types
The Entity API provides a unified interface for CRUD operations and metadata on all entity types including nodes, taxonomy terms, and users.
Question 2: What is the purpose of Drupal's 'hook_cron()' implementation?
- To define tasks that run periodically when Drupal cron executes (Correct answer)
- To schedule database backups automatically
- To clear caches on a timer
- To send email digests on a schedule
Correct answer: To define tasks that run periodically when Drupal cron executes
Modules implement hook_cron() to register cleanup, aggregation, or maintenance tasks that run each time Drupal's cron is triggered.
Question 3: Which Drupal feature allows content editors to preview layout changes without affecting the live site?
- Layout Builder with draft/preview support via Content Moderation (Correct answer)
- The theme switcher
- Revision history
- The block layout overlay
Correct answer: Layout Builder with draft/preview support via Content Moderation
Combining Layout Builder with the Content Moderation module lets editors build draft layouts that only go live after editorial approval.
Question 4: What is 'field formatter' in Drupal's field system?
- A plugin that controls how a field's value is displayed to end users (Correct answer)
- A validator that checks field input on save
- A widget that renders the editing UI for a field
- A migration plugin for importing field data
Correct answer: A plugin that controls how a field's value is displayed to end users
Field formatters are display plugins; for example, an image field can be formatted as a thumbnail, full image, or URL using different formatters.
Question 5: In Drupal's Migrate API, what is the role of a 'source plugin'?
- To read data from the origin system (CSV, database, JSON, etc.) (Correct answer)
- To transform data between systems
- To write migrated data into Drupal entities
- To track which items have already been migrated
Correct answer: To read data from the origin system (CSV, database, JSON, etc.)
Source plugins connect to and iterate over data from the origin — Drupal 6/7, CSV files, JSON endpoints, or custom databases.
Question 6: What does enabling Drupal's 'Maintenance mode' do?
- Takes the site offline for anonymous users and shows a maintenance message (Correct answer)
- Disables all non-core modules
- Prevents new user registrations
- Stops cron from running
Correct answer: Takes the site offline for anonymous users and shows a maintenance message
Maintenance mode presents a configurable offline message to non-admin visitors while administrators can still access the site.
Question 7: Which Drupal module type provides reusable 'render arrays' output via a defined plugin interface?
- Block plugins (Correct answer)
- Field modules
- Theme hooks
- Action plugins
Correct answer: Block plugins
Block plugins implement BlockPluginInterface and return a render array from their build() method, making them placeable in any region.
In Drupal, what is the 'Entity API' primarily used for?