public function sep__protocol_formatter::view
3.x sep__protocol_formatter.inc | public sep__protocol_formatter::view(&$element, $entity_type, $entity, $langcode, $items, $display) |
Provides the display for a field
This function corresponds to the hook_field_formatter_view() function of the Drupal Field API.
This function provides the display for a field when it is viewed on the web page. The content returned by the formatter should only include what is present in the $items[$delta]['values] array. This way, the contents that are displayed on the page, via webservices and downloaded into a CSV file will always be identical. The view need not show all of the data in the 'values' array.
Parameters
$element:
$entity_type:
$entity:
$langcode:
$items:
$display:
Return value
An element array compatible with that returned by the hook_field_formatter_view() function.
Overrides TripalFieldFormatter::view
File
- tripal_chado/
includes/ TripalFields/ sep__protocol/ sep__protocol_formatter.inc, line 83
Class
- sep__protocol_formatter
- @class Purpose:
Code
public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
if (count($items) > 0) {
$protocol_id = $items[0]['value']["protocol_id"];
$protocol_name = $items[0]['value']["protocol_name"];
$content = $protocol_name;
list($entity_type, $entity_id) = explode(':', $items[0]['value']['entity_id']);
if ($entity_id) {
$content = l($protocol_name, 'bio_data/' . $entity_id);
}
}
//cardinality for this field is 1
$element[0] =[
'#type' 'markup'
'#markup' $content
];
}