Commit 363c9fe9 authored by Damien McKenna's avatar Damien McKenna Committed by Damien McKenna
Browse files

Issue #3356420 by DamienMcKenna, jwilson3, PapaGrande: Character count on...

Issue #3356420 by DamienMcKenna, jwilson3, PapaGrande: Character count on fields via Maxlength integration.
parent 5c781de3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ Metatag 8.x-1.x-dev, 2022-xx-xx
#3359952 by DamienMcKenna: Rename logo file to just "logo.png".
#3351558 by parisek, DamienMcKenna: Translation of meta tags is limited to 128
  characters.
#3356420 by DamienMcKenna, jwilson3, PapaGrande: Character count on fields via
  Maxlength integration.


Metatag 8.x-1.22, 2022-09-29
+4 −0
Original line number Diff line number Diff line
@@ -91,6 +91,10 @@ functionality:
  Adds support for the Cxense meta tags used by their DMP and Insight services.
- [Metatag Google Scholar](https://www.drupal.org/project/metatag_google_scholar):
  Adds support for a number of meta tags used with the Google Scholar system.
- [Maxlength](https://www.drupal.org/project/maxlength):
  If this module is installed, meta tags that have a maximum length defined in
  the settings will have that maximum length enforced; this may be disabled in
  the settings if it proves to be problematic.


## Installation
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@ entity_type_groups: { }
tag_trim_method: beforeValue
tag_trim_maxlength: { }
tag_scroll_max_height: ''
use_maxlength: true
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@ metatag.settings:
    tag_trim_method:
      type: string
      label: 'Trim method for trimmable tags.'
    use_maxlength:
      type: boolean
      label: 'Use Maxlength module to force these limits?'
    tag_trim_maxlength:
      type: sequence
      label: 'Tag-specific maximum length'
+14 −0
Original line number Diff line number Diff line
@@ -120,6 +120,18 @@ class MetatagSettingsForm extends ConfigFormBase {
      '#description' => $this->t("Many Meta-Tags can be trimmed on a specific length for search engine optimization.<br/>If the value is set to '0' or left empty, the whole Metatag will be untrimmed."),
    ];

    // Optional support for the Maxlenth module.
    $form['tag_trim']['use_maxlength'] = array(
      '#type' => 'checkbox',
      '#title' => $this->t('Use Maxlength module to force these limits?'),
      '#default_value' => $this->config('metatag.settings')->get('use_maxlength') ?? TRUE,
      '#description' => $this->t('Because of how tokens are processed in meta tags, use of the Maxlength module may not provide an accurate representation of the actual current length of each meta tag, so it may cause more problem than it is worth. '),
    );
    if (!\Drupal::moduleHandler()->moduleExists('maxlength')) {
      $form['tag_trim']['use_maxlength']['#disabled'] = TRUE;
      $form['tag_trim']['use_maxlength']['#description'] = $this->t('Install the Maxlength module to enable this option.');
    }

    $form['tag_trim']['maxlength'] = [
      '#title' => $this->t('Tags'),
      '#type' => 'fieldset',
@@ -191,6 +203,8 @@ class MetatagSettingsForm extends ConfigFormBase {
    $settings->set('entity_type_groups', $entityTypeGroupsValues);

    // tag_trim handling:
    $use_maxlength = $form_state->getValue(['tag_trim', 'use_maxlength']);
    $settings->set('use_maxlength', $use_maxlength);
    $trimmingMethod = $form_state->getValue(['tag_trim', 'tag_trim_method']);
    $settings->set('tag_trim_method', $trimmingMethod);
    $trimmingValues = $form_state->getValue(['tag_trim', 'maxlength']);
Loading