I encountered an issue on a Drupal 11 site recently where I had a block that was rendering an entity to display on a page.
There was nothing unusual about what was going on in the rendering process, but in this case I needed to add some attributes to the entity markup and I found that this process wasn't that simple. The solution was to intercept the rendering process half way through using a pre-rendering callback method.
As it wasn't that simple I took some notes and decided to convert them into an article to show how to do the same. In this article we will look at using the view builder to generate a renderable view of an entity and then look at how to alter the attributes of the view mode without using a preprocess hook.
Rendering An Entity
To get a content entity ready for rendering we need to use the entity_type.manager service to get the correct view builder for the entity in question. Once we have the view builder object we can use the view() method to get our renderable array.
For example, assuming that we have a Media entity of some sort, we get that entity ready for rendering using the following.
The $mediaView variable will now contain the array needed to render the entity using the "default" view mode for the entity. The contents of the array depends on what you are rendering, but if its a media entity then the entity object will be present, along with the view builder object, the view mode and theme of the entity, and some cache information.
You click "Add to Cart" and a little notification pops up: "Item added!" You submit a form and see "Thank you, your message has been sent." You start typing in a search box and results appear below as you type. These instant feedback messages are everywhere on modern websites - but are they accessible to everyone?
For sighted users, these visual cues are obvious. But for someone using a screen reader, these dynamic updates can be completely invisible unless they're coded properly. The page content changed, but their screen reader said nothing about it.
Advent Calendar day 6 - From starters to solid Drupal team membersjames
An important aspect of building a sustainable community is bringing new people into Drupal organisations, and helping them to embrace the community. Today Jess Vetsuypers and Eline Van Coillie from Dropsolid talk about finding and retaining new talent.
They discuss some interesting approaches in both finding and evaluating potential team members, and then ensuring they integrate well into your organisation.
I particularly liked their use of LEGO as part of the selection process with a live building challenge as part of the talk. It's a shame the recording is audio only, as it would have been…
Summary of the developer meetup held on November 9, 2025, in Kobe, Japan, and co-organized by W3C and NTT Docomo Business, along the annual TPAC 2025 event where the global web community met to coordinate the development of Web standards.
The ODRL Policy Recommendation, finalised in 2018, is gaining global adoption across industries. Adopted by JPEG Trust, IDSA, DSSC, Gaia-X, and EUIPO, ODRL enables machine-readable rights, usage, and governance policies. Its flexibility and broad applicability highlight industry needs, with future standardisation now under community consideration.
W3C explored how Threat Modeling with LEGO SERIOUS PLAY can help uncover security, privacy, and human-rights threats in digital identity systems. Participants built threats from real-world harms, mapped them into shared landscapes, and discovered they are connected.
It's here! Almost. jQuery 4.0.0-rc.1 is now available. It's our way of saying, "we think this is ready; now poke it with many sticks". If nothing is found that requires a second release candidate, jQuery 4.0.0 final will follow. Please try out this release and let us know if you encounter any issues. A 4.0 … Continue reading →
Last February, we released the first beta of jQuery 4.0.0. We're now ready to release a second, and we expect a release candidate to come soon™. This release comes with a major rewrite to jQuery's testing infrastructure, which removed all deprecated or under-supported dependencies. But the main change that warranted a second beta was a … Continue reading →
jQuery's influence on the web will always be evident. When it was first introduced in 2006, jQuery became a fundamental tool for web developers almost immediately. It simplified JavaScript programming, making it easier to manipulate HTML documents, handle events, perform animations, and much more. Since then, it has played and continues to play a major … Continue reading →
When it comes to crafting an article, the headline is crucial for grabbing the reader's attention and enticing them to read further. In this post, I'll explore the 7 types of article headlines and provide examples for each using the subjects of product management, user experience design, and search engine optimization. 1. The Know-it-All The […]
Product management is one of the most exciting and rewarding careers in the tech world. But it's also one of the most misunderstood and misrepresented. There are many myths and misconceptions that cloud the reality of what product managers do, how they do it, and what skills they need to succeed. In this blog post, […]
The role of a product manager is crucial to the success of any product. They are responsible for managing the entire product life cycle, from conceptualization to launch and beyond. A product manager must possess a unique blend of skills and qualities to be effective in their role. Strong strategic thinking A product manager must […]