You are here

function fieldable_panels_panes_entity_label_callback in Fieldable Panels Panes (FPP) 7

Callback function for the FPP entity label.

1 string reference to 'fieldable_panels_panes_entity_label_callback'
fieldable_panels_panes_entity_info in ./fieldable_panels_panes.module
Implements hook_entity_info().


./fieldable_panels_panes.module, line 1540
Maintains an entity that appears as panel pane content.


function fieldable_panels_panes_entity_label_callback($entity, $type) {

  // First, try the real label.
  if (!empty($entity->admin_title)) {
    return $entity->admin_title;

  // Then, the user visible title.
  if (!empty($entity->title)) {
    return $entity->title;

  // Then, the bundle label with FPID.
  $info = entity_get_info($type);
  if (!empty($info['bundles'][$entity->bundle]['label'])) {
    return t('@label (id: @fpid)', array(
      '@label' => $info['bundles'][$entity->bundle]['label'],
      '@fpid' => $entity->fpid,

  // Finally, the ultimate fallback: the entity name with bundle and FPID.
  return t('@label (type: @bundle, id: @fpid)', array(
    // FYI, we use $info['label'] rather than the literal string in case it was
    // translated.
    '@label' => $info['label'],
    '@bundle' => $entity->bundle,
    '@fpid' => $entity->fpid,