div around fields and static fields at top, for orgs and cases
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
use Drupal\Core\Render\Element;
|
||||
use Drupal\opencase;
|
||||
|
||||
/**
|
||||
* Prepares variables for Case templates.
|
||||
@ -20,18 +21,6 @@ use Drupal\Core\Render\Element;
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
*/
|
||||
function template_preprocess_oc_case(array &$variables) {
|
||||
// Separate the fields into two sections to be displayed in two columns.
|
||||
// Remove the name (title) field as this is displayed anyway.
|
||||
$variables['id'] = $variables['elements']['#oc_case']->get('id')[0]->get('value')->getValue();
|
||||
$variables['base_fields'] = array();
|
||||
$variables['other_fields'] = array();
|
||||
foreach (Element::children($variables['elements']) as $key) {
|
||||
$variables['content'][$key] = $variables['elements'][$key];
|
||||
if (in_array($key, ['created', 'changed', 'files', 'actors_involved', 'status', 'user_id'])) {
|
||||
$variables['base_fields'][$key] = $variables['elements'][$key];
|
||||
} else {
|
||||
$variables['other_fields'][$key] = $variables['elements'][$key];
|
||||
unset($variables['other_fields']['name']);
|
||||
}
|
||||
}
|
||||
_template_preprocess_entity($variables);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,10 @@
|
||||
*/
|
||||
#}
|
||||
<div{{ attributes.addClass('oc_case') }}>
|
||||
{% if content %}
|
||||
{{- content -}}
|
||||
{% if normal_fields %}
|
||||
<div id='static_data'>{{- normal_fields -}}</div>
|
||||
{% endif %}
|
||||
{% if extra_fields %}
|
||||
<div id='dynamic_data'>{{- extra_fields -}}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -20,11 +20,5 @@ use Drupal\Core\Render\Element;
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
*/
|
||||
function template_preprocess_oc_organisation(array &$variables) {
|
||||
// Fetch OCOrganisation Entity Object.
|
||||
$oc_organisation = $variables['elements']['#oc_organisation'];
|
||||
|
||||
// Helpful $content variable for templates.
|
||||
foreach (Element::children($variables['elements']) as $key) {
|
||||
$variables['content'][$key] = $variables['elements'][$key];
|
||||
}
|
||||
_template_preprocess_entity($variables);
|
||||
}
|
||||
|
@ -16,7 +16,10 @@
|
||||
*/
|
||||
#}
|
||||
<div{{ attributes.addClass('oc_organisation') }}>
|
||||
{% if content %}
|
||||
{{- content -}}
|
||||
{% if normal_fields %}
|
||||
<div id='static_data'>{{- normal_fields -}}</div>
|
||||
{% endif %}
|
||||
{% if extra_fields %}
|
||||
<div id='dynamic_data'>{{- extra_fields -}}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user