Allow which metatags are visible on the field widget to be editable

Created on 22 January 2020, over 5 years ago
Updated 17 July 2023, almost 2 years ago

Say I only want to expose a couple meta tags as editable to my node forms, but I want all the metatags to still work with defaults. I think adding a setting to the MetatagFieldItem that limits the editable tags would be a good solution. I think this works best on the field setting level, instead of the widget, so that way the settings can be implemented by all possible field widgets (including the firehose widget).

✨ Feature request
Status

Needs review

Version

2.0

Component

User interface

Created by

🇺🇸United States dave reid Nebraska USA

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.3 & MySQL 5.7
    last update almost 2 years ago
    Patch Failed to Apply
  • 🇩🇪Germany atropoides Hamburg

    I rerolled the patch to 2.0.0.
    For now I'm not able to set the branch to 2.0.x and provide a merge request, hope someone else can do it.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update almost 2 years ago
    113 pass
  • 🇩🇪Germany atropoides Hamburg
  • 🇧🇪Belgium bramvandenbulcke

    This would be a welcome addition to the Metatags module! The forms are too long now and contain obsolete information:

    • The Basic tags contain two fields that are no longer supported. This information clutters the interface.
    • The Open Graph tags form is really long.

    I mostly try to avoid printing the form for website editors (mostly by using a summary field) but sometimes they want a custom metatag description.

    I'm currently hiding the unused metatags in Seven with some CSS (I use a small custom module to override the admin styling):

    #edit-field-metatags-0-basic .form-item,
    #edit-field-metatags-0-open-graph .form-item {
    	display: none;
    }
    
    #edit-field-metatags-0-basic .form-item.form-item-field-metatags-0-basic-title,
    #edit-field-metatags-0-basic .form-item.form-item-field-metatags-0-basic-description,
    #edit-field-metatags-0-open-graph .form-item.form-item-field-metatags-0-open-graph-og-title,
    #edit-field-metatags-0-open-graph .form-item.form-item-field-metatags-0-open-graph-og-description {
    	display: block;
    }
    

    This will expose only the meta title and description on the basic and Open Graph fields. It's a dirty solutions but it helps to clean up the interface.

  • Status changed to RTBC over 1 year ago
  • 🇫🇮Finland kirsij

    Changing the status as I have successfully applied this patch.

  • 🇨🇦Canada mrogers

    Anyone have any success re-rolling against 2.1?

  • First commit to issue fork.
  • 🇪🇸Spain vengador Seville

    Re-rolled patch against 2.1.x branch and created MR.

  • Pipeline finished with Failed
    8 months ago
    Total: 319s
    #335351
  • 🇬🇧United Kingdom scott_euser
  • First commit to issue fork.
  • 🇭🇺Hungary balagan

    Thanks for the patch. It's working fine with metatag 2.1.0. Just adding my 2 cents that using the small select box is not the best UX.

  • 🇫🇮Finland Aelfendir

    I tested the merge request and it seemed to work perfectly (Metatag 2.1.0, D10.3.9). Thank you for the great feature!

    I agree with balagan that selection of multiple fields with the current widget was not super easy/intuitive. But the ability to select the editable metatags in the first place is a huge improvement. I don't have any better suggestions at the moment.

  • 🇬🇧United Kingdom scott_euser

    scott_euser → changed the visibility of the branch metatag-3108108 to hidden.

  • 🇬🇧United Kingdom scott_euser

    scott_euser → changed the visibility of the branch 3108108-allow-which-metatags to active.

  • 🇬🇧United Kingdom scott_euser

    scott_euser → changed the visibility of the branch 8.x-1.x to hidden.

  • Pipeline finished with Failed
    2 months ago
    Total: 493s
    #481502
  • 🇬🇧United Kingdom scott_euser

    Hmmm can't seem to get the fork to sync from upstream repo, not sure if its because I'm not the owner of the fork. No possibility to create a new fork from 2.1.x. I could create a new issue, but shame to lose all the history

  • 🇬🇧United Kingdom scott_euser

    scott_euser → changed the visibility of the branch 2.1.x to hidden.

  • 🇬🇧United Kingdom scott_euser

    scott_euser → changed the visibility of the branch 3108108-allow-which-metatags to hidden.

  • Pipeline finished with Failed
    2 months ago
    Total: 520s
    #481504
  • 🇬🇧United Kingdom scott_euser
  • Pipeline finished with Failed
    2 months ago
    Total: 536s
    #481509
  • Pipeline finished with Success
    2 months ago
    Total: 284s
    #481564
  • 🇬🇧United Kingdom scott_euser

    Okay sorted for 2.1.x. Tests pass again BUT this could use more test coverage for the new functionality.

    I also implemented a variation of @jrockowitz suggestion to improve the UX with checkboxes rather than select multiple.

    For those updating to this patch, since update hooks are not done between patch versions, the simplest is to:

    1. Control + F your config/sync/ directory for 'editable_tags'
    2. Nest them within the tag group ID like this diff below:
     settings:
       editable_tags:
    -    title: title
    -    description: description
    +    basic:
    +      title: title
    +      description: description
    
  • Pipeline finished with Failed
    2 months ago
    Total: 357s
    #481588
  • Pipeline finished with Success
    2 months ago
    Total: 451s
    #481591
  • 🇬🇧United Kingdom scott_euser

    Added test coverage as well. Existing phpstan/d12 depreciations should remain out of scope.

    Would be great if someone can review so we can get this fairly long standing one in.

    Thanks!

  • 🇬🇧United Kingdom altcom_neil

    Hi,

    Just updated a site to Drupal 10.4.7 and Metatag 2.1.1 and using the diff from the MR the Metatags are configurable per field instance.

    Attached in the patch file to use in composer patch json (we don't link directly to the drupalcode diff file for security and stability reasons) based on the commits upto d6d6d892 .

    Note that for anyone using the earlier patches then you need to reconfigure each field due to the change from the select list to the checkboxes but I think checkboxes are definitely more user friendly.

    Also, I was thinking there must have been a bug somewhere as I was seeing the following metatag fields 'Max Snippet', 'Max Video Preview', 'Max Image Preview', and 'Unavailable after date' but no way to manage them. But diving into the code I found they were part of the Robots plugin. Not sure if there is a UI way to make that a little more obvious or whether it would make the admin page too cluttered. This isn't really an issue with this code more a general one - only it is more obvious with this code as you cannot turn those sub fields off.

    Cheers, Neil

  • 🇳🇱Netherlands dennisdk

    Fixed the error "TypeError: array_filter(): Argument #1 ($array) must be of type array, string given in array_filter()" in this patch, based upon the patch #89 which applied to 2.1.1 cleanly.

  • 🇪🇸Spain escuriola

    An updated patch ready for version 2.1.1

  • 🇫🇮Finland sokru
Production build 0.71.5 2024