In progress of adding revision views & making entity displays nicer

This commit is contained in:
Naomi
2020-05-13 15:41:59 +01:00
parent b83f0b44b4
commit 18e32335f5
10 changed files with 164 additions and 53 deletions

View File

@ -20,11 +20,17 @@ use Drupal\Core\Render\Element;
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_oc_actor(array &$variables) {
// Fetch OCActor Entity Object.
$oc_actor = $variables['elements']['#oc_actor'];
// Helpful $content variable for templates.
// Make the id available to the template and also separate the fields
// into two sections to be displayed in two columns.
$variables['id'] = $variables['elements']['#oc_actor']->get('id')[0]->get('value')->getValue();
$variables['contact_details'] = array();
$variables['fields_other_than_contact_details'] = array();
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
if (in_array($key, ['email', 'phone', 'phone2', 'postal_address', 'post_code'])) {
$variables['contact_details'][$key] = $variables['elements'][$key];
} else {
$variables['fields_other_than_contact_details'][$key] = $variables['elements'][$key];
}
}
}