When you add fieldable panel panes to a reference field, and the display formatting is set to 'rendered entity'. A fatal error pops up.

This is because 'entity_metadata_view_single' is used als view callback, and this function uses "$function = $entity_type . '_view';" to view this entity.

Comments

nils.destoop’s picture

StatusFileSize
new1.75 KB

Patch attached to change all the view functions to fieldable_panel_pane_view

nils.destoop’s picture

Status: Active » Needs review
nils.destoop’s picture

Maybe the other functions (load functions, fieldable_panels_panes_create, fieldable_panels_panes_access, fieldable_panels_panes_save) should also be renamed?

merlinofchaos’s picture

Status: Needs review » Postponed (maintainer needs more info)

I'm sorry, what fatal error do you refer to? Are you making a change because the metadata module is hardcoding what the names of our view callbacks should be? I'm very confused by this change.

swentel’s picture

Status: Postponed (maintainer needs more info) » Active

So here's the irony: The Entity API module has Field API formatters which allows you to select a formatter to render an entity through a view mode. The callback for that is entity_metadata_view_single(), however, it looks at the entity_type name - see below. In case of the fieldable panels panes module, the entity key is 'fieldable_panels_pane', but the callback to view it is 'fieldable_panels_panes_view', that's why the undefined function error pops up.

function entity_metadata_view_single($entities, $view_mode = 'full', $langcode = NULL, $entity_type) {
  $function = $entity_type . '_view';
  $build = array();
  foreach ($entities as $key => $entity) {
    $build[$entity_type][$key] = $function($entity, $view_mode, $langcode);
  }

  return $build;
}

I haven't tested whether it's possible to change the view callback in the entity info to fieldable_panels_pane_view, but I hope this info makes it a bit clearer?
(note, it probably happens in other occasions as well outside field api formatters, but not sure)

merlinofchaos’s picture

Yes it should be possible to change this in the entity info somewhere. I'd start by trying 'view callback'?

nils.destoop’s picture

I tried changing the view callback first. But then following fatal error occures: ': Trying to get property of non-object in PanelsPaneController->view()'

When dsm'ing, the value of $entity is an array with entities, instead of an entity on it's own.

theunraveler’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB

zuuperman is correct: it looks like the view callback is given an array with one entity. I've adjusted the fieldable_panels_panes_view() function to react accordingly if the argument is an array. I'm not sure if this is the best way to deal with this.

dave reid’s picture

Status: Needs review » Fixed

This change looks acceptable and allows compatibility with entity API, so committing to #8 to 7.x-1.x. http://drupalcode.org/project/fieldable_panels_panes.git/commit/4031576

Status: Fixed » Closed (fixed)

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

dave reid’s picture

Status: Closed (fixed) » Needs work

Committing #8 made fieldable panel panes incompatible with the 'Rendered entity' row plugin in Views.

dave reid’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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