diff --git a/core/themes/olivero/config/install/olivero.settings.yml b/core/themes/olivero/config/install/olivero.settings.yml index 1e5d0344dbe..a4248de13b7 100644 --- a/core/themes/olivero/config/install/olivero.settings.yml +++ b/core/themes/olivero/config/install/olivero.settings.yml @@ -13,3 +13,4 @@ third_party_settings: mobile_menu_all_widths: 0 site_branding_bg_color: default base_primary_color: '#1b9ae4' +comment_form_position: 0 diff --git a/core/themes/olivero/config/schema/olivero.schema.yml b/core/themes/olivero/config/schema/olivero.schema.yml index 0bd946db287..aa72e00ffe2 100644 --- a/core/themes/olivero/config/schema/olivero.schema.yml +++ b/core/themes/olivero/config/schema/olivero.schema.yml @@ -38,3 +38,6 @@ olivero.settings: base_primary_color: type: color_hex label: 'Base Primary Color' + comment_form_position: + type: integer + label: 'Comment form position' diff --git a/core/themes/olivero/olivero.post_update.php b/core/themes/olivero/olivero.post_update.php index f033945e02b..a7272268385 100644 --- a/core/themes/olivero/olivero.post_update.php +++ b/core/themes/olivero/olivero.post_update.php @@ -13,3 +13,12 @@ function olivero_post_update_add_olivero_primary_color() { ->set('base_primary_color', '#1b9ae4') ->save(); } + +/** + * Sets the `comment_form_position` value of Olivero's theme settings. + */ +function olivero_post_update_add_comment_form_position() { + \Drupal::configFactory()->getEditable('olivero.settings') + ->set('comment_form_position', 0) + ->save(TRUE); +} diff --git a/core/themes/olivero/olivero.theme b/core/themes/olivero/olivero.theme index 6d4aa96bb0b..c502d98c765 100644 --- a/core/themes/olivero/olivero.theme +++ b/core/themes/olivero/olivero.theme @@ -540,6 +540,8 @@ function olivero_preprocess_field__comment(&$variables) { $variables['#cache']['contexts'][] = 'user'; } + + $variables['comment_form_position'] = theme_get_setting('comment_form_position'); } /** diff --git a/core/themes/olivero/templates/field/field--comment.html.twig b/core/themes/olivero/templates/field/field--comment.html.twig index c69553cea34..9a07538eee3 100644 --- a/core/themes/olivero/templates/field/field--comment.html.twig +++ b/core/themes/olivero/templates/field/field--comment.html.twig @@ -42,6 +42,10 @@ {{ title_suffix }} {% endif %} + {% if comment_form_position %} + {{ comments }} + {% endif %} + {% if comment_form %}
{% if user_picture %} @@ -57,6 +61,8 @@
{% endif %} - {{ comments }} + {% if not comment_form_position %} + {{ comments }} + {% endif %} diff --git a/core/themes/olivero/theme-settings.php b/core/themes/olivero/theme-settings.php index 849df4c11d5..805261e329e 100644 --- a/core/themes/olivero/theme-settings.php +++ b/core/themes/olivero/theme-settings.php @@ -117,4 +117,14 @@ function olivero_form_system_theme_settings_alter(&$form, FormStateInterface $fo ], ]; } + + $form['olivero_settings']['olivero_utilities']['comment_form_position'] = [ + '#type' => 'radios', + '#title' => t('Comment form position'), + '#options' => [ + 0 => t('Before comments'), + 1 => t('After comments'), + ], + '#default_value' => theme_get_setting('comment_form_position'), + ]; }