Commit 27ce0a5e authored by George's avatar George
Browse files

Issue #3264064 by lashabp, matsbla, geoanders: Move related content from...

Issue #3264064 by lashabp, matsbla, geoanders: Move related content from sidebar to under the title field.
parent 12731536
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ function anti_duplicates_form_node_form_alter(&$form, FormStateInterface $form_s
          $msg = t("Help us reduce the chance of duplicated content, if we find content that is similar or related to the one you are posting it will be listed below :");
        }

        if (!$config->get('anti_duplicates_placement')) {
          // Add a "Related content" details.
          $form['anti_duplicates'] = [
            '#type' => 'details',
@@ -49,6 +50,7 @@ function anti_duplicates_form_node_form_alter(&$form, FormStateInterface $form_s
            '#weight' => -100,
            '#open' => TRUE,
          ];
        }

        // Add an Ajax callback to the title field.
        $form['title']['widget'][0]['value']['#ajax'] = [
+12 −0
Original line number Diff line number Diff line
@@ -114,6 +114,17 @@ class AntiDuplicatesAdminForm extends ConfigFormBase {
      '#description' => $this->t('Select content types you want to use the anti duplicates for. If none are selected, no restriction based on types will be implemented.'),
    ];

    $form['anti_duplicates_placement'] = [
      '#type' => 'radios',
      '#title' => $this->t('Placement of notice message'),
      '#options' => [
        0 => $this->t('Right sidebar'),
        1 => $this->t('Under the title'),
      ],
      '#description' => $this->t('Choose where the notice message will be placed.'),
      '#default_value' => $config->get('anti_duplicates_placement') ?? 0,
    ];

    $form['anti_duplicates_display_not_zero'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Display related content only in case of more than 0 results'),
@@ -136,6 +147,7 @@ class AntiDuplicatesAdminForm extends ConfigFormBase {
      ->set('anti_duplicates_form_submission', $values['anti_duplicates_form_submission'])
      ->set('anti_duplicates_search_type', $values['anti_duplicates_search_type'])
      ->set('anti_duplicates_content_types', is_array($values['anti_duplicates_content_types']) ? $values['anti_duplicates_content_types'] : [])
      ->set('anti_duplicates_placement', $values['anti_duplicates_placement'])
      ->set('anti_duplicates_display_not_zero', $values['anti_duplicates_display_not_zero'])
      ->save();