Hello,

In my content, I have a body field of type "Text (formatted, long, with summary)".

When I use the default body field, the meta tag works.

If I replace the default body field, with a text field (formatted, long, with summary) custom field_page_body, it does not work.

An idea ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zenimagine created an issue. See original summary.

DamienMcKenna’s picture

Priority: Major » Normal
Issue tags: +Needs tests

I suspect this is a bug in the token system, which Metatag doesn't actually get involved in.

That said, lets put together a test for your scenario and see what happens.

zenimagine’s picture

@DamienMcKenna
Have you managed to reproduce the problem?
If yes, do you have a solution?
Thank you

Dakwamine’s picture

I have had a similar bug, but it was on [node:summary]. For some reason, if I put a white space after the token, the tag works. You can try this as a workaround.

zenimagine’s picture

I followed your comment and it works. But with the token it displays the complete body of the node, how to display only the first 150 characters?

zenimagine’s picture

When I create a node, it is written under summary :

"Leave blank to use the short value of the full text as a summary."

I leave the summary empty. It should create an ausume automatically using the short value of the full text. No ?

zenimagine’s picture

In fact it works, I have the summary that corresponds to the first paragraph of my full text.

But why does not "Metatag" cut the texe to 150 characters

Is there a way to deal with this ?

(Search engines recommend 150 characters).

zenimagine’s picture

Finally there is a problem.
When I use the default "body" field it works.
If I replace the default field with a text field (formatted, long, with summary) "field_page_body", and I add the [node:field_page_body:summary] to "Metatag" token, this does not work not.

Same for [node:summary]

The [node:field_page_body] token works but with the full text.

The problem then comes from the summary token of the custom fields (formatted, long, with summary).

An idea ?

zenimagine’s picture

DamienMcKenna’s picture

I'm sorry you're having this problem. I haven't been able to look into this problem yet as I was moving last month.

We need tests for a few different scenarios:

  • Standard node summary works when the node's body field has summary text.
  • Standard node summary works when the node's body field does not have summary text.
  • Custom node longtext+summary works using a field token when the field has summary text.
  • Custom node longtext+summary works using a field token when the field does not have summary text.

There is a separate issue for truncating meta tags to a specific length: #2309017: Automatically trim meta tag lengths (D7)

zenimagine’s picture

For me :
Custom node longtext+summary does not work using a field token when the field does not have summary text.

Thank you for linking the length of the description. But is there a patch on drupal 8 ?

DamienMcKenna’s picture

There's nothing on that issue for D8, but once it's included in D7 (probably 7.x-1.23) we'll look to porting it to D8.

zenimagine’s picture

Perfect thank you keep me informed :-) And if someone can test and confirm me has a custom field problem that does not work.

zenimagine’s picture

Have you reproduced the problem?

DamienMcKenna’s picture

Not yet.

zenimagine’s picture

Title: The token description does not work on the field is empty » The "Meta description" tag does not work if the body field is not the default.
zenimagine’s picture

Status: Active » Needs work
DamienMcKenna’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#1671420: If no body field, [node:summary] [node:body] etc tokens are not replaced

This is a known issue in the Token system, sorry. See #1671420: If no body field, [node:summary] [node:body] etc tokens are not replaced for a discussion on the problem.

zenimagine’s picture

This question is not duplicated. See the comment #8

zenimagine’s picture

Status: Closed (duplicate) » Needs work
DamienMcKenna’s picture

Do you have the Entity Token module installed, or just the basic Token module?

zenimagine’s picture

I installed the following module :

https://www.drupal.org/project/token

Metatags works with the token, but not if the body field "body" has been replaced with a field "body_article" for example.

DamienMcKenna’s picture

Status: Needs work » Active

Ultimately the problem with token values not giving the correct value is not Metatag's fault, which is why I closed the issue in the first place.

Lets go back to writing some tests.

zenimagine’s picture

Have you duplicated for testing?

1) Create a content type (eg recipe).
2) Delete the default body field.
3) Create a field body_recipe
4) In the Matatag settings for this type of content, add the corresponding token to the body.

The personalized body tag does not display any items. But it works perfectly with other module.

Why ?

There is a problem with the Metetag module.

zenimagine’s picture

Issue summary: View changes
DamienMcKenna’s picture

Out of interest, do you have HTML at the beginning of the summary?

zenimagine’s picture

No.
With body it works.
If I do a copy paste my text into a body_recipe field it does not work.

zenimagine’s picture

Status: Active » Needs work
zenimagine’s picture

FileSize
106.52 KB
179.32 KB
223.83 KB
107.25 KB
152.94 KB
190.86 KB

Screenshot 0, 1, 2 :

When I use the default body field, the meta description is correctly displayed.

Screenshot 4, 5, 6 :

When I do not use the default body field, the meta description is empty.

Can you do a test on simplytest.me ?
And confirm the problem ?

Thank you

DamienMcKenna’s picture

Status: Needs work » Active

Thanks for all the screenshots, that helps.

Just to mention it, "needs work" is for where there's a patch that needs further work, it isn't just a way of saying "this needs to be worked on"; "active" is the correct status to use until we have a patch to look at.

DamienMcKenna’s picture

So I installed core 8.4 with Metatag, added a new long text field to the default Article content type and used the token browser to see what tokens were available for the content type:
Token browser

I also noticed that the summary field is not editable, so I edited an issue for that: #2906282: No summary option showing for "Text area with a summary" widget

DamienMcKenna’s picture

Just out of interest, have you checked to see the field via the Devel module to see if the summary contains anything? I wonder if that's why the summary field isn't outputting anything, that it doesn't have any text?

DamienMcKenna’s picture

Title: The "Meta description" tag does not work if the body field is not the default. » "summary" token for text+summary field is empty when using anything other than the core "body" field

Clarifying the title - it seems to be a general problem with the text+summary field.

zenimagine’s picture

The token [node:field_article_body:summary] does not work, but the token [node:field_article_body] works (the text is too long for the description).

Sorry, I have no devel.

zenimagine’s picture

Did you reproduce the problem ?

DamienMcKenna’s picture

I thought I'd posted an updated comment. Sorry.

Yes, there are some core issues related to this and the core maintainers are looking to delete the field type entirely: #1378350: Clean up the "Long text and summary" field

I do want to write tests, though, just to confirm the functionality.

zenimagine’s picture

To date, there is no way for the module to support the customized "Body" fields (the fields created by the kernel and replaced by a custom field) ?

DamienMcKenna’s picture

The problem isn't the text fields themselves, it's the "summary" token.

DamienMcKenna’s picture

As a work-around you might try filing something into the "summary" portion of those text fields.

zenimagine’s picture

Do I open a problem with the "Token" module ?

DamienMcKenna’s picture

I really think the problem is in core, but it could be worked around in the contrib module.

John_B’s picture

[node:summary] is also not replaced (on my site, at least) where field_data_body is set in the content type to permit unlimited values rather than a single value.

This is D7, so I fear it may be difficult to get attention of core devs, or at any rate core committers, for it.

joseph.olstad’s picture

Just noticed this. Appears to still be an issue.

There is an available patch for the token module.

#2924873: Summary token not fully handled in fields

DamienMcKenna’s picture

joseph.olstad’s picture

The patch here:
#2924873-11: Summary token not fully handled in fields

Is working well for us.

It's being held up on a "Needs tests" tag.