Blog
Display a config value in your theme page.html.twig file in drupal 8 or 9
Often we create a custom settings form with stuff like social media url's or addresses. With this snippet you make the variables available in your page.twig.html file.
Blog
Render a block programmatically in twig with drupal 8 or 9
In the early days of Drupal 8 we used the EntityTypeManager to render some plugin blocks or other entities. But this changed a bit. Here's a snippet on how to render a block inside your twig files.
Blog
Set media image url with image style token for meta image in drupal 8 & 9
Image url is a must-have for webpages to be properly shareable on social media. With this token snippet you can set a media entity url with image style token.
Blog
Redirect taxonomy terms to filtered view page
A common case when using facet searches is where you want to list some terms and when people click on them you get redirected to a filtered view. This code helps you with that.
Blog
Loop through entity reference in Twig to get id's in drupal 8
Entity references are widely used in drupal to link to other entity objects. Here's how to loop over them in a twig file.
Blog
Check if entity object is of entity type node
<p>There are some ways to make sure your loaded object is in fact an entity of type node. I prefer the following way. In addition I check if the entity types are correct too.</p>
Blog
Add html to a menu links in drupal 8 (twig)
I found a nice way to build complex menu's with twig in Html. Here are a few snippets
Blog
How to update a custom entity in drupal 8 once installed: add a field
Custom entities provide great control and flexibility because your entire entity resides in code. This snippet shows how to add a field to your entity, with an update hook. Because once the entity is installed, you should be able to add/remove/edit your fields.
Blog
Create an extra tab on the user log in page
I had a case where an extra tab was necessary on the user pages. This snippets show you how to do it.
Blog
Redirect form after registration in drupal 8
Sometimes it is needed for a user to be redirected after registration. The user is not logged in yet, and has to go to a landing page with more instructions on verifying his e-mail.
Pagination
- Previous page
- Page 23
- Next page