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

Issue fork metatag-3318164

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ninobrownh20 created an issue. See original summary.

fwust’s picture

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

trickfun’s picture

Same error for me.
Drupal 11.1
Column is empty

trickfun’s picture

StatusFileSize
new2.23 KB

The patch show correct value.

tostinni’s picture

@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

shivam_tiwari’s picture

trickfun’s picture

@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?

aditi saraf’s picture

Assigned: Unassigned » aditi saraf

I am working on this issue

trickfun’s picture

@aditi saraf try my patch
thank you

aditi saraf’s picture

StatusFileSize
new115.76 KB
new128.52 KB

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.

aditi saraf’s picture

Assigned: aditi saraf » Unassigned
aditi saraf’s picture

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

trickfun’s picture

@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

aditi saraf’s picture

StatusFileSize
new82.56 KB

@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

trickfun’s picture

@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.

aditi saraf’s picture

@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.

trickfun’s picture

You need to use MetatagFormatter not EmptyFormatter.

aditi saraf’s picture

@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).

trickfun’s picture

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

damienmckenna’s picture

Version: 8.x-1.22 » 2.1.x-dev