render_box: adding addAge option

This commit is contained in:
Mathieu Jaumotte 2021-07-30 11:13:54 +02:00
parent 175d6892ec
commit 08cd6c81f2
3 changed files with 8 additions and 5 deletions

View File

@ -7,6 +7,7 @@
* addEntity bool * addEntity bool
* addId bool * addId bool
* addInfo bool * addInfo bool
* addAge bool
* hLevel integer * hLevel integer
* customButtons [ * customButtons [
'before' Twig\Markup, (injected with macro) 'before' Twig\Markup, (injected with macro)
@ -60,6 +61,11 @@
{{ 'Born the date'|trans({'gender': person.gender, {{ 'Born the date'|trans({'gender': person.gender,
'birthdate': person.birthdate|format_date("medium") }) }} 'birthdate': person.birthdate|format_date("medium") }) }}
</time> </time>
{%- if options['addAge'] -%}
<span class="age">
{{ person.age ~ ((person.age > 1) ? ' ans' : ' an') }}
</span>
{%- endif -%}
</p> </p>
{%- endif -%} {%- endif -%}
{#- tricks to remove easily whitespace after template -#} {#- tricks to remove easily whitespace after template -#}

View File

@ -5,9 +5,8 @@
<div class="col-md-6"> <div class="col-md-6">
{{ person|chill_entity_render_box({ {{ person|chill_entity_render_box({
'render': 'label', 'addInfo': true, 'addId': true, 'hLevel': 1 'render': 'label', 'addInfo': true, 'addAge': true, 'addId': true, 'hLevel': 1
}) }} }) }}
</div> </div>
<div class="col-md-auto ps-4 ps-md-2"> <div class="col-md-auto ps-4 ps-md-2">
@ -68,9 +67,6 @@
{% else %} {% else %}
{{ person.birthdate|format_date('short') }} {{ person.birthdate|format_date('short') }}
{% endif %} {% endif %}
<span class="age">
{{ person.age ~ ((person.age > 1) ? ' ans' : ' an') }}
</span>
</div> </div>
{%- if chill_person.fields.nationality == 'visible' -%} {%- if chill_person.fields.nationality == 'visible' -%}

View File

@ -57,6 +57,7 @@ class PersonRender extends AbstractChillEntityRender
'addEntity' => $options['addEntity'] ?? false, 'addEntity' => $options['addEntity'] ?? false,
'addId' => $options['addId'] ?? false, 'addId' => $options['addId'] ?? false,
'addInfo' => $options['addInfo'] ?? false, 'addInfo' => $options['addInfo'] ?? false,
'addAge' => $options['addAge'] ?? false,
'hLevel' => $options['hLevel'] ?? 3, 'hLevel' => $options['hLevel'] ?? 3,
'customButtons' => $options['customButtons'] ?? [], 'customButtons' => $options['customButtons'] ?? [],
]; ];