Blog
How to render button with class from Route in drupal 8, 9, 10
With the following snippet you can create a link or button with classes from a route.
Blog
Five ways of using the path twig function for route links in drupal 8, 9 or 10
Linking to routes in Twig has become much easier since the release of some updates in Drupal 8. Here are 5 snippets that help when linking to internal routes.
Blog
How to use entityQuery Exists condition with entity reference
This snippet returns TRUE or FALSE if an entity has a filled-in value on a entity reference on field_winner field.
Blog
How to pass variables to html render arrays with FormattableMarkup in drupal 8, 9 and 10
Mixing HTML with variables is common practice when developing custom applications. This snippet shows how to mix HTML and variables the correct way.
Blog
Rendering a node or entity single field only programmatically in Drupal 8, 9 or 10
You do not always want to render a full output or your entity. This useful snippet teaches you how to render a single field value output.
Blog
Link to a route in twig [Drupal 8, 9, 10]
You should never hardcode your URLs in drupal. They might change. Use the following generic method instead.
Blog
Get the url of an image in drupal 9 & 10 with an image style in twig
Sometimes you need the URL of an image in twig in order to use it as a background image or something. While there are ways to load them in twig, it is more appropriate to do this with a preprocess function. This makes your code more maintainable.
Blog
Altering autocomplete results on entity references in drupal 9 & 10
The core autocomplete on entity references is not always satisfying. Sometimes authors need to know published status etc. This blogpost guides you through all the steps.
Blog
Render output of a node programmatically in drupal 9
There are use cases where you want the rendered output programmatically. This is different in drupal 9. This snippet shows you how to get it.
Blog
Creating twig views template suggestions for a custom entity
I had this views field in a view that renders custom entities. Unfortunately, the suggestions do not come out of the box. Here is how to add them.