Problem/Motivation

Custom Meta tags: Handle empty values

Steps to reproduce

  • There's an article content type in the website. Add non-mandatory multivalued entity reference taxonomy term field_tags.
  • Create a new custom tag "term" and add the following to the metatag settings. [node:field_tags:0:entity:field_key],[node:field_tags:1:entity:field_key],[node:field_tags:2:entity:field_key],[node:field_tags:3:entity:field_key]
  • Create a new article content and do not select any value in tags field

Proposed resolution

Remove the empty values

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork metatag-3491230

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

naveenvalecha created an issue. See original summary.

naveenvalecha’s picture

Status: Active » Needs work
Issue tags: +Needs tests

I have opened the PR with the fix.
We need tests which I'll add later

keshav patel’s picture

Although purpose is clear from the issue title, still the issue summary needs to be updated.

naveenvalecha’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests, -Needs issue summary update
radimklaska’s picture

I just tested this functionality and the missing tokens are correctly skipped. Thanks Naveen!

eleonel’s picture

Status: Needs review » Reviewed & tested by the community

Working fine for me too, after applying #5 the meta tags with empty value are gone.

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs work

Won't this remove valid strings which fail empty(), like the number zero?

I think this should be changed to loop over each element of the array and run the old check.

naveenvalecha’s picture

Should I close this as duplicate of #3378434: Empty values not removed from multi-value meta tags as it is solving in generic way for all plugins

damienmckenna’s picture

Status: Needs work » Closed (duplicate)
Parent issue: » #3378434: Empty values not removed from multi-value meta tags

Yes, let's do that.