Add sort by count option to file listing view.
Edit the Files view.
Configure the table display settings.
Check the sortable box for File usage.
Save and view the file listing page.
Sort by file usage to find unused files.
Replace the hardcoded node meta info with a configurable view.
The idea here is to replace the part of the node template where author/date is printed with a view block placed in layout builder.
Create view called Node meta, listing content, unsorted.…
To change multiple parts of an Attributes object in twig, merge it with an object keyed with updated attributes.
Use the output to create a new attributes object and overwrite the attributes variable.
{% set attributes = create_attribute(attributes|merge…
Drupal provides some layouts by default.
Layout Builderhttps://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/layout_builder/layout_builder.layouts.yml?ref_type=heads
Layout Discoveryhttps://git.drupalcode.org/project/drupal/-/blob/11.x/core/…
When an ajax event is fired in Drupal, the ajax loader appears briefly then disappears.
This makes it hard to theme!
To make it appear and stick around, set an XHR breakpoint in your browser debugger.
Image
Now trigger the ajax event.
Image…
Pathauto provides hooks for modifying aliases, but if you want to write an update hook to modify a set of custom entity aliases, it is not as simple as setting the path when Pathauto is not installed.
Pathauto puts an option to automatically generate the…
The CKEditor module allows placing separators and wrappers in the toolbar.
If there are no separators, they are automatically grouped when overflowing.
See the full options here: https://ckeditor.com/docs/ckeditor5/latest/getting-started/setup/toolbar.…
DDEV will sync your project directory.
You can sync some files into your home directory by symlinking into ~/.ddev/homeadditions or PROJECT/.ddev/homeadditions.
https://ddev.readthedocs.io/en/stable/users/extend/in-container-configuration/
However, if you…
Locale is an OS language setting.
I encountered warnings when running drush sql-sync.
> > perl: warning: Setting locale failed.
> > perl: warning: Please check that your locale settings:
> > LANGUAGE = (unset),
> > LC_ALL = (…
Imagemagick is a graphics manipulation library.
Imagick is the PHP extension.
The version of Debian used in DDEV does not have php8.3 libraries available in the package manager yet.
https://packages.debian.org/stable/php/php-imagick
However, there is a…
The latest imagick release in pecl repositories is not yet compatible with 8.3.
The workaround is to compile it manually by cloning the repo and running make commands inside the docker container.
Here's how to do it in lando:
.lando.yml
services:…
Create a command that uses drush sql-sync to import a prod db to a local multisite installation.
*You must have the @remote.SITE and @local.SITE drush aliases set up.
tooling:
db-sync:
service: appserver
cmd: site=${0} && drush sql-sync…
When adding a block in Layout Builder, it is an inline block by default.
To create a reusable block, first go to Structure > Block layout > Custom block library.
User Picture is a property on the User entity.
It's created via the standard profile.
If you used minimal or a custom profile, you may not have this in your site.
To get it back, copy these files from core/profiles/standard/config/install to your site's…
node.module defines a theme hook for node_edit_form, but it is not used by default.
Claro applies it to node forms with:
function claro_form_node_form_alter(&$form, FormStateInterface $form_state) {
$form['#theme'] = ['node_edit_form'];
$form['#…
Search API can index relationships. To use them, add the relationship and select the field under the Content Relationship category.
Image
You may want to transform a value in a twig template.
You can do that by checking a condition on the value in an if, and provide values in the then/else.
{% set newvalue = value == 'asdf' ? '123': '456' %}If you have different inputs and outputs, you can…
Telephone is a module included in core, but may not installed by default depending on the profile you use.
If you try to uninstall a module with Drush and get an error "There is content for the entity type", you can go to the uninstall modules page which will allow you to delete them and uninstall.
If that fails, try drush sqlq "truncate ENTITY_NAME" which…
If you have a content type that references other items of the same type, the referenced items may not be available when the parent is migrated. Drupal migrations can create stubbed entities for these items using the Migration Lookup process plugin. If…