public function PanelsPaneController::buildContent in Fieldable Panels Panes (FPP) 7
Builds a structured array representing the fieldable panel pane's content.
Parameters
object $entity: A Fieldable Panels Pane entity.
string $view_mode: View mode, e.g. 'full', 'teaser'...
string $langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
1 call to PanelsPaneController::buildContent()
- PanelsPaneController::view in includes/
PanelsPaneController.class.php - Display a given FPP object.
File
- includes/
PanelsPaneController.class.php, line 319 - Contains the controller class for the Fieldable Panel Pane entity.
Class
- PanelsPaneController
- Entity controller class.
Code
public function buildContent($entity, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Remove previously built content, if exists.
$entity->content = array();
// Add the title so that it may be controlled via other display mechanisms.
$entity->content['title'] = array(
'#theme' => 'html_tag',
'#tag' => 'h2',
'#value' => '',
);
// Some titles link to a page.
if (!empty($entity->title)) {
if (!empty($entity->link) && !empty($entity->path)) {
$entity->content['title']['#value'] = l($entity->title, $entity->path);
}
else {
$entity->content['title']['#value'] = check_plain($entity->title);
}
}
// Allow modules to change the view mode, trigger
// hook_entity_view_mode_alter().
$context = array(
'entity_type' => 'fieldable_panels_pane',
'entity' => $entity,
'langcode' => $langcode,
);
drupal_alter('entity_view_mode', $view_mode, $context);
// Build fields content.
field_attach_prepare_view('fieldable_panels_pane', array(
$entity->fpid => $entity,
), $view_mode, $langcode);
entity_prepare_view('fieldable_panels_pane', array(
$entity->fpid => $entity,
), $langcode);
$entity->content += field_attach_view('fieldable_panels_pane', $entity, $view_mode, $langcode);
// Trigger hook_fieldable_panels_pane_view().
module_invoke_all('fieldable_panels_pane_view', $entity, $view_mode, $langcode);
// Trigger hook_entity_view().
module_invoke_all('entity_view', $entity, 'fieldable_panels_pane', $view_mode, $langcode);
// Make sure the current view mode is stored if no module has already
// populated the related key.
$entity->content += array(
'#view_mode' => $view_mode,
);
}