ctools_entity_field_extra_content_type_render() tries to get extra field content by using hooks (hook_entity_view and hook_ENTITYTYPE_view). This works great if extra fields are added by additional modules, but if the extra field is defined in the entity module itself and is rendered in entity module _view functon, this fails. The real example is taxonomy term description field. It can't be shown by current ctools. The provided patch tries to solve this problem, but more general solution is welcomed.

Comments

maximpodorov’s picture

StatusFileSize
new1.5 KB

Updated patch. $langcode was in the wrong place.

andypost’s picture

+++ b/plugins/content_types/entity_context/entity_field_extra.incundefined
@@ -97,13 +97,20 @@ function ctools_entity_field_extra_content_type_render($subtype, $conf, $panel_a
+  $function = $entity_type . '_view';
+  if (in_array($entity_type, array('node', 'taxonomy_term', 'user')) && function_exists($function)) {
+    // Call known ENTITY_view() to get the extra field.
+    $entity->content = $function($entity, $conf['view_mode'], $langcode);
+  }
+  else {
...
+    module_invoke_all($entity_type . '_view', $entity, $conf['view_mode'], $langcode);

this needs elsif for comment_view() which have different signature

maximpodorov’s picture

What extra fields defined in comment module are subjects of this issue?

andypost’s picture

Author and subject @see comment_field_extra_fields()

maximpodorov’s picture

They are form-level fields, and can't be shown in a simple way.

sk33lz’s picture

This patch fixes an issue we had with a custom module implementation of hook_field_extra_fields.

sk33lz’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Reviewed and tested against 7.x-1.x-dev.

jody lynn’s picture

andypost’s picture

The approach in #1907800: Extra fields need the fully built entity is different that does not care about specific implementations, so I'd like current issue way

andypost’s picture

@Jody Lynn - see taxonomy_term_build_content() you can't see term description without that so patch here is right fix

damienmckenna’s picture

This could potentially save some headaches in Metatag getting Panels-driven entities to display correctly..

japerry’s picture

Status: Reviewed & tested by the community » Fixed

Fixed! Talking with some other devs, it looks like the comment issue shouldn't be a problem here.

http://drupalcode.org/project/ctools.git/commit/992d22a

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.