actu node/N show summary + body
This commit is contained in:
parent
754cce927a
commit
cc2f1e4d41
@ -35,12 +35,41 @@ function quartiers_de_demain_preprocess_page(&$variables) {
|
||||
* Implements hook_preprocess_HOOK() for node.html.twig.
|
||||
*/
|
||||
function quartiers_de_demain_preprocess_node(&$variables) {
|
||||
$node = &$variables['node'];
|
||||
$variables['attributes']['class'][] = 'node-type-' . $node->gettype();
|
||||
$node = &$variables['node'];
|
||||
$variables['attributes']['class'][] = 'node-type-' . $node->gettype();
|
||||
|
||||
if ($node->getType() === 'actualite'
|
||||
&& $variables['view_mode'] === 'full'
|
||||
&& $node->hasField('body')) {
|
||||
|
||||
$summary = $node->get('body')->summary;
|
||||
$full = $node->get('body')->value;
|
||||
|
||||
if (!empty($summary) || !empty($full)) {
|
||||
$variables['content']['body'] = [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => '
|
||||
{% if summary %}
|
||||
<div class="body-summary">{{ summary|raw }}</div>
|
||||
{% endif %}
|
||||
{% if full %}
|
||||
<div class="body-full">{{ full|raw }}</div>
|
||||
{% endif %}
|
||||
',
|
||||
'#context' => [
|
||||
'summary' => $summary,
|
||||
'full' => $full,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* implements template_preprocess_region() */
|
||||
|
||||
function quartiers_de_demain_preprocess_region(&$variables) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user