Drupal Drupal 5 — Questions and Answers
Question 1: What is the purpose of Drupal's 'routing.yml' file in a custom module?
- To define URL paths and map them to controller classes (Correct answer)
- To configure HTTP redirects site-wide
- To set caching rules for specific URLs
- To declare REST API endpoints for Views
Correct answer: To define URL paths and map them to controller classes
Each route in modulename.routing.yml specifies a path, the controller method to call, and any access requirements.
Question 2: In Drupal, what distinguishes a 'custom block type' from a 'simple block'?
- A custom block type has configurable fields managed via the Field UI, while a simple block has fixed output (Correct answer)
- A custom block type is only available in the sidebar
- Simple blocks support revisions; custom block types do not
- Custom block types cannot be reused across regions
Correct answer: A custom block type has configurable fields managed via the Field UI, while a simple block has fixed output
Custom block types are fieldable entities that editors fill out in the admin UI, whereas plugin-based blocks have hardcoded structure.
Question 3: What is 'Big Pipe' in Drupal?
- A technique that streams the page to the browser while placeholder content is loaded asynchronously (Correct answer)
- A database connection pooling module
- A CDN integration for large file delivery
- A theme that improves CSS delivery speed
Correct answer: A technique that streams the page to the browser while placeholder content is loaded asynchronously
The BigPipe module sends cacheable parts of the page immediately and fills in personalized (uncacheable) placeholders via subsequent streaming chunks.
Question 4: Which Drupal core module provides token-based placeholder support used in email templates and path aliases?
- Token (Correct answer)
- Placeholder
- Tokenizer
- Text Format
Correct answer: Token
The Token module (core in D10) exposes system values like [node:title] or [user:name] that can be used dynamically in text fields.
Question 5: In Drupal's REST module, which format is used by default when POSTing to create a new entity via the API?
- JSON (application/json)
- XML (text/xml)
- HAL+JSON (application/hal+json) (Correct answer)
- Form-encoded (application/x-www-form-urlencoded)
Correct answer: HAL+JSON (application/hal+json)
Drupal's core REST module defaults to HAL+JSON which includes hypermedia links alongside entity data for entity create/update operations.
Question 6: What is the significance of Drupal's 'trusted host patterns' configuration?
- It prevents HTTP Host header injection attacks by whitelisting allowed hostnames (Correct answer)
- It restricts which IP addresses can access the admin panel
- It defines which CDN domains can serve cached pages
- It controls which external domains can be linked from content
Correct answer: It prevents HTTP Host header injection attacks by whitelisting allowed hostnames
Trusted host patterns in settings.php ensure Drupal rejects requests with forged Host headers, which could be used for cache poisoning or phishing.
Question 7: When using Drupal's Layout Builder, what is a 'section' in the layout context?
- A horizontal strip of the page with a defined column structure that holds blocks (Correct answer)
- A separate page within a multi-page content type
- A permission group controlling who sees a layout area
- A CSS class applied to a template region
Correct answer: A horizontal strip of the page with a defined column structure that holds blocks
In Layout Builder, each section defines a column layout (e.g., two-column) and editors place blocks into the section's columns.
What is the purpose of Drupal's 'routing.yml' file in a custom module?