Make CTools compatible with hook_field_attach_view_alter()

Created on 27 March 2014, over 10 years ago
Updated 13 August 2024, 3 months ago

The module currently uses field_formatter_settings_get_instance_display_settings() from the Field Formatter Settings module to load the formatters settings and grab the CSS classes. This will not work with fields that have their formatter settings stored differently to Drupal's default view mode / bundles settings storage. There does not seem to be a guaranteed way to get the field instance's formatter settings from within field_formatter_class_preprocess_field(), especially with CTools content panes. However there is another way that should always work when the field is being rendered in a non-view-mode dependant way (E.g. Panelizer). If we use hook_field_attach_view_alter() we get given the exact settings the field is about to be rendered with, prior to rendering. And as the field is a render array we can pass additional properties that will be included with the theme's variables.

A patch is attached that does just this. The side affect of this patch is if the sole use case for the site is to set the fields using CTools Content Pane/Panelizer. The module need not depend on Field Formatter Settings. But I think that would be another discussion to have.

Note this will not work out of the box with CTools because of issue #1928054: Field formatter settings with CTool content_type entity_field plugin (Panels integration) β†’ . A patch in the report resolves this.

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom magicmyth

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024