-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
TwigTwig template processingTwig template processingenhancementNew feature or requestNew feature or requestmetadataMeta(l) dataMeta(l) data
Milestone
Description
What is needed?
We have JSON-LD (super simple, just one of our metadata displays exposing Schema.org, see Google's response to this or directly at.
Well now its time to put this into each ADOs Page header. Code is simple, and something like this
/**
* Implements hook_page_attachments_alter().
*/
function format_strawberryfield_page_attachments_alter(array &$attachments) {
// Check first if it has a SBF field... Code here!
// Fetch content of some Metadata Display that is of JSON-LD and is marked as SEO enabled (need a setting)
$jsonld = parseMetadaDisplay('somedisplay', $nodeid); // Or something in that tone, we have the methods already.. need to look for the code
if ($jsonld) {
$attachments['#attached']['html_head'][] = [
[
'#type' => 'html_tag',
'#tag' => 'script',
'#value' => $jsonld,
'#attributes' => ['type' => 'application/ld+json'],
],
];
}
}
}This is way simpler and more powerful for our needs (less setting up) than the schema.org metadata module that exists for Drupal 8. Also less processing. Can be combined with it if someone wants to do this for Normal Content with like 100 fields.
@giancarlobi what do you think? I will also share the Twig Template/Metadata display, which will be shipped by default with Beta3!
Metadata
Metadata
Assignees
Labels
TwigTwig template processingTwig template processingenhancementNew feature or requestNew feature or requestmetadataMeta(l) dataMeta(l) data