Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 ?
Comment | File | Size | Author |
---|---|---|---|
#31 | metatag-n2885825-tokenbrowser.png | 86.58 KB | DamienMcKenna |
#29 | 6.png | 190.86 KB | zenimagine |
#29 | 5.png | 152.94 KB | zenimagine |
#29 | 4.png | 107.25 KB | zenimagine |
#29 | 2.png | 223.83 KB | zenimagine |
Comments
Comment #2
DamienMcKennaI 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.
Comment #3
zenimagine CreditAttribution: zenimagine commented@DamienMcKenna
Have you managed to reproduce the problem?
If yes, do you have a solution?
Thank you
Comment #4
DakwamineI 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.Comment #5
zenimagine CreditAttribution: zenimagine commentedI 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?
Comment #6
zenimagine CreditAttribution: zenimagine commentedWhen 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 ?
Comment #7
zenimagine CreditAttribution: zenimagine commentedIn 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).
Comment #8
zenimagine CreditAttribution: zenimagine commentedFinally 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 ?
Comment #9
zenimagine CreditAttribution: zenimagine commentedComment #10
DamienMcKennaI'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:
There is a separate issue for truncating meta tags to a specific length: #2309017: Automatically trim meta tag lengths (D7)
Comment #11
zenimagine CreditAttribution: zenimagine commentedFor 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 ?
Comment #12
DamienMcKennaThere'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.
Comment #13
zenimagine CreditAttribution: zenimagine commentedPerfect thank you keep me informed :-) And if someone can test and confirm me has a custom field problem that does not work.
Comment #14
zenimagine CreditAttribution: zenimagine commentedHave you reproduced the problem?
Comment #15
DamienMcKennaNot yet.
Comment #16
zenimagine CreditAttribution: zenimagine commentedComment #17
zenimagine CreditAttribution: zenimagine commentedComment #18
DamienMcKennaThis 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.
Comment #19
zenimagine CreditAttribution: zenimagine commentedThis question is not duplicated. See the comment #8
Comment #20
zenimagine CreditAttribution: zenimagine commentedComment #21
DamienMcKennaDo you have the Entity Token module installed, or just the basic Token module?
Comment #22
zenimagine CreditAttribution: zenimagine commentedI 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.
Comment #23
DamienMcKennaUltimately 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.
Comment #24
zenimagine CreditAttribution: zenimagine commentedHave 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.
Comment #25
zenimagine CreditAttribution: zenimagine commentedComment #26
DamienMcKennaOut of interest, do you have HTML at the beginning of the summary?
Comment #27
zenimagine CreditAttribution: zenimagine commentedNo.
With body it works.
If I do a copy paste my text into a body_recipe field it does not work.
Comment #28
zenimagine CreditAttribution: zenimagine commentedComment #29
zenimagine CreditAttribution: zenimagine commentedScreenshot 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
Comment #30
DamienMcKennaThanks 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.
Comment #31
DamienMcKennaSo 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:
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
Comment #32
DamienMcKennaJust 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?
Comment #33
DamienMcKennaClarifying the title - it seems to be a general problem with the text+summary field.
Comment #34
zenimagine CreditAttribution: zenimagine commentedThe 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.
Comment #35
zenimagine CreditAttribution: zenimagine commentedDid you reproduce the problem ?
Comment #36
DamienMcKennaI 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.
Comment #37
zenimagine CreditAttribution: zenimagine commentedTo 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) ?
Comment #38
DamienMcKennaThe problem isn't the text fields themselves, it's the "summary" token.
Comment #39
DamienMcKennaAs a work-around you might try filing something into the "summary" portion of those text fields.
Comment #40
zenimagine CreditAttribution: zenimagine commentedDo I open a problem with the "Token" module ?
Comment #41
DamienMcKennaI really think the problem is in core, but it could be worked around in the contrib module.
Comment #42
John_B CreditAttribution: John_B commented[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.
Comment #43
joseph.olstadJust 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
Comment #44
DamienMcKennaComment #45
joseph.olstadThe 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.