When creating a specific template for a display mode using the Mailchimp module (or any other module), you need to follow Drupal's theming conventions to ensure your template is recognized and used. In this case, it seems that the template naming might be causing the issue.
To create a template for a specific display mode, follow these steps:
Check the Display Mode Machine Name:
Double-check the machine name of the display mode you've created. This is the name you'll use in your template file naming.
Use Correct Naming Convention:
To create a template for a specific display mode, you should follow the naming convention: node--node-type--display-mode.html.twig
.
In your case, if your content type is "article" and the display mode is "mailchimp", the template file should be named: node--article--mailchimp.html.twig
.
Make sure that this template file is placed in your theme's templates folder.
Clear Cache:
After adding the template file, clear Drupal's cache to ensure the changes are recognized. You can do this using Drush or via the Drupal admin interface.
Verify Your Theme:
Ensure that you're modifying the template in the correct active theme. Sometimes, if you have a sub-theme, you need to add the template to the sub-theme's templates folder.
Debugging:
If the template still doesn't seem to be recognized, you can enable Twig debugging to get more information about template suggestions. To do this, edit your services.yml
file and set debug: true
for Twig:
parameters:
twig.config:
debug: true
After enabling Twig debugging, you'll see template suggestions in HTML comments in your rendered page's source code. This will help you verify that you're using the correct template name.
Remember that template suggestions are hierarchical, so Drupal will use the most specific template suggestion available. Following the naming convention is crucial for Drupal to recognize and use your custom template for the desired display mode.