You are here

function PanelizerEntityDefault::get_default_display in Panelizer 7.3

Same name and namespace in other branches
  1. 7.2 plugins/entity/PanelizerEntityDefault.class.php \PanelizerEntityDefault::get_default_display()

Provide a default display for newly panelized entities.

This should be implemented by the entity plugin.

Overrides PanelizerEntityInterface::get_default_display

6 calls to PanelizerEntityDefault::get_default_display()
PanelizerEntityComment::get_default_display in plugins/entity/PanelizerEntityComment.class.php
Provide a default display for newly panelized entities.
PanelizerEntityDefault::get_internal_default_panelizer in plugins/entity/PanelizerEntityDefault.class.php
An internal representation of a panelizer object, used to seed when we have none and want something to get started.
PanelizerEntityDefault::hook_entity_load in plugins/entity/PanelizerEntityDefault.class.php
PanelizerEntityNode::get_default_display in plugins/entity/PanelizerEntityNode.class.php
Provide a default display for newly panelized entities.
PanelizerEntityTaxonomyTerm::get_default_display in plugins/entity/PanelizerEntityTaxonomyTerm.class.php
Provide a default display for newly panelized entities.

... See full list

4 methods override PanelizerEntityDefault::get_default_display()
PanelizerEntityComment::get_default_display in plugins/entity/PanelizerEntityComment.class.php
Provide a default display for newly panelized entities.
PanelizerEntityNode::get_default_display in plugins/entity/PanelizerEntityNode.class.php
Provide a default display for newly panelized entities.
PanelizerEntityTaxonomyTerm::get_default_display in plugins/entity/PanelizerEntityTaxonomyTerm.class.php
Provide a default display for newly panelized entities.
PanelizerEntityUser::get_default_display in plugins/entity/PanelizerEntityUser.class.php
Provide a default display for newly panelized entities.

File

plugins/entity/PanelizerEntityDefault.class.php, line 2921
Base class for the Panelizer Entity plugin.

Class

PanelizerEntityDefault
Base class for the Panelizer Entity plugin.

Code

function get_default_display($bundle, $view_mode) {

  // This is a straight up empty display.
  $display = panels_new_display();
  $display->layout = 'flexible';
  $panes = array();
  foreach (field_info_instances($this->entity_type, $bundle) as $field_name => $instance) {
    $view_mode_settings = field_view_mode_settings($this->entity_type, $bundle);
    $actual_mode = !empty($view_mode_settings[$view_mode]['custom_settings']) ? $view_mode : 'default';
    $field_display = $instance['display'][$actual_mode];
    $pane = panels_new_pane('entity_field', $this->entity_type . ':' . $field_name, TRUE);
    $pane->configuration['formatter'] = $field_display['type'];
    $pane->configuration['formatter_settings'] = $field_display['settings'];
    $pane->configuration['label'] = $field_display['label'];
    $pane->configuration['context'] = 'panelizer';
    $panes[] = array(
      '#pane' => $pane,
      '#weight' => $field_display['weight'],
    );
  }

  // Use our #weights to sort these so they appear in whatever order the
  // normal field configuration put them in.
  uasort($panes, 'element_sort');
  foreach ($panes as $pane) {
    $display
      ->add_pane($pane['#pane'], 'center');
  }
  return $display;
}