Hello, yes the same thing happens to me too. But I have configured FAQField as a custom block and I get blank. If I put fixed text if it is shown.
In pivot it always comes out empty (no fields).I have tried:
[node:field_faq]
[node:field_faq:answer]
[node:field_faq:question][block_content:field_faq:0]
[block_content:field_faq:0:answer]
[block_content:field_faq:0:question]But no results.
Can you guide me?
Thanks- π¨π΄Colombia jucedogi
To @ReVija or anyone else wondering still.
The latest version of schema_metatag does support this.
You must take care of the multiple value separator that you must define in the settings page for the metatag module. Default is ",".
From there you must select the "Pivot" option and assing the text value with the multiple options separated with the properly assigned separator character. Take care that the text values do not include said character.
In my case tokens were defined as:
- [node:field_faq:0:question];[node:field_faq:1:question];[node:field_faq:2:question];[node:field_faq:3:question]
and
- [node:field_faq:0:answer];[node:field_faq:1:answer];[node:field_faq:2:answer];[node:field_faq:3:answer]
- πΊπ¦Ukraine oleksandr p. Lutsk
oleksandr p. β made their first commit to this issueβs fork.
- πΊπ¦Ukraine oleksandr p. Lutsk
oleksandr p. β changed the visibility of the branch 3284608-faq-field-pivot to hidden.
- πΊπ¦Ukraine oleksandr p. Lutsk
I investigated this and a similar issue https://www.drupal.org/project/schema_metatag/issues/3341248 π¬ Faq Field Pivot for Schema Active , and can conclude that this issue is very specific, and schema logic generally works as designed.
For a more correct FAQPage structure with the faq field, I use the following hook:
/** * Changes the FAQPage structure for correct metatags schema implementation. * * Implements hook_metatags_attachments_alter(). */ function module_name_metatags_attachments_alter(array &$metatag_attachments) { $head_content = &$metatag_attachments['#attached']['html_head']; $qa_pages = []; foreach ($head_content as $head_key => $content) { if ($content[1] === 'schema_qa_page_type') { $qa_pages[] = $head_key; } if ($content[1] === 'schema_qa_page_main_entity_0') { $qa_pages[] = $head_key; $faq_schema = []; $node = \Drupal::routeMatch()->getParameter('node'); if ($node instanceof NodeInterface && $node->hasField('field_faqs')) { $faq_content = $node->get('field_faqs')->getValue(); if (!empty($faq_content)) { foreach ($faq_content as $key => $faq_item) { $faq_schema[$key] = [ '@type' => 'Question', 'name' => preg_replace("/\r|\n/", '', strip_tags($faq_item['question'])), 'text' => preg_replace("/\r|\n/", '', strip_tags($faq_item['question'])), 'acceptedAnswer' => [ '@type' => 'Answer', 'text' => preg_replace("/\r|\n/", '', strip_tags($faq_item['answer'])), ], ]; } $head_content[$head_key][0]['#attributes']['content'] = $faq_schema; } else { // Removes FAQPage metatags schema from the general list. foreach ($qa_pages as $page_key) { unset($head_content[$page_key]); } } } } } }
And I need to mention that this solution, in my opinion, is a better way to solve this issue.
Hope I helped someone with it.
- π¬π·Greece denizserhat
question: [node:field_faq:0:question],[node:field_faq:1:question],[node:field_faq:2:question],[node:field_faq:3:question],[node:field_faq:4:question]
answer: [node:field_faq:0:answer],[node:field_faq:1:answer],[node:field_faq:2:answer],[node:field_faq:3:answer],[node:field_faq:4:answer]
I filled in the fields as above. I have 5 questions and 5 answers, although the question fields work correctly, it places all 5 answers in the same order under each question. Pivot options are enabled. How can I fix this?