Meta description always blank in view

Created on 29 October 2022, over 2 years ago
Updated 18 October 2023, over 1 year ago

Problem/Motivation

When trying to create a view with meta description as one of the fields for the view, the meta description is always blank even if there is a meta description for the pages in the view.

Steps to reproduce

Create a view with meta description as a field.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.22

Component

Views integration

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

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

  • 🇫🇷France fwust Strasbourg

    I tried to reproduce the problem with last 8.x-1.26 version. The meta description is well displayed.

  • 🇮🇹Italy trickfun

    Same error for me.
    Drupal 11.1
    Column is empty

  • 🇮🇹Italy trickfun

    The patch show correct value.

  • 🇫🇷France tostinni

    @trickfun, can you detail a little bit more how to reproduce this bug, like @fwust I tested on a views page and the meta description is correctly displayed.
    Thanks

  • 🇮🇹Italy trickfun

    @tostinni, create a simple view of articles.
    When i add metatag field i have only the "Empty formatter" in the formatter select.
    The formatter code is:

    /**
     * Plugin implementation of the 'metatag_empty_formatter' formatter.
     *
     * @FieldFormatter(
     *   id = "metatag_empty_formatter",
     *   module = "metatag",
     *   label = @Translation("Empty formatter"),
     *   field_types = {
     *     "metatag"
     *   }
     * )
     */
    class MetatagEmptyFormatter extends FormatterBase {
    
      /**
       * {@inheritdoc}
       */
      public function viewElements(FieldItemListInterface $items, $langcode) {
        // Does not actually output anything.
        return [];
      }
    
    }
    
    

    How can print meta values if the formatter returns empty array?

  • 🇮🇳India aditi saraf

    I am working on this issue

  • 🇮🇹Italy trickfun

    @aditi saraf try my patch
    thank you

  • 🇮🇳India aditi saraf

    i try to reproduce this issue on drupal 11.0.0 . For this i installed metatag , meta tag: view module .And added meta tag field in view . And saved it. I just added some dummy value for meta tag ang in result i can see all the added meta tag. It is working for me . Attaching screenshot below.

  • 🇮🇳India aditi saraf

    @trickfun just seeing your comment but i already tried it and for me it is working. Thanks

  • 🇮🇹Italy trickfun

    @aditi saraf
    The problem is not the metatag into html page but the value of metatag in view table.
    Add metatag field to your view and show me the result table with metatag column.

    The metatag column is empty.
    Thank you

  • 🇮🇳India aditi saraf

    @trickfun i am trying to add metatag as a field in view, but i am not getting any option to add meta tag as a fied. Let me know if i need to install any module for this. I already have meat tag and metatag: view module configured. Attached a file here for same

  • 🇮🇹Italy trickfun

    @aditi saraf
    - go to node article configuration page
    - add metatag field to node
    - go to your view
    - setup you view as table of fields
    - add new field to view. search for metatag field name.
    - run the view
    - the metatag column field is empty.

  • 🇮🇳India aditi saraf

    @trickfun thanks for helping me to reproduce this issue. I tried to apply your patch but still in view metatag field is empty. How everempty formatter is not coming.

  • 🇮🇹Italy trickfun

    You need to use MetatagFormatter not EmptyFormatter.

  • 🇮🇳India aditi saraf

    @trickfun after using meta tag i am getting following issue
    Drupal\Component\Plugin\Exception\PluginException: Plugin (metatag_empty_formatter) instance class "Drupal\metatag\Plugin\Field\FieldFormatter\MetatagEmptyFormatter" does not exist. in Drupal\Component\Plugin\Factory\DefaultFactory::getPluginClass() (line 97 of C:\wamp64\www\dummydr\web\core\lib\Drupal\Component\Plugin\Factory\DefaultFactory.php).

  • 🇮🇹Italy trickfun

    Have you clean the cache?
    Look inside metatag\Plugin\Field\FieldFormatter if MetatagEmptyFormatter exists.
    Thank you

Production build 0.71.5 2024