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.
Hi all,
I'm trying to modify the og:description metatag fro a specific node type, so here what I did:
function myModule_metatag_metatags_view_alter(&$output, $instance) {
if ($instance == 'node:media_gallery') {
if (isset($output['og:description']['#attached']['drupal_add_html_head'][0][0]['#value'])) {
$output['og:description']['#attached']['drupal_add_html_head'][0][0]['#value'] = _myModule_get_description();
}
}
}
Now I have to write the callback function _myModule_get_description() where I'm going to build the description based on some fields belonging to the node.
The problem is that I don't know how to retrieve these node information (nid, fields and so on) from here.
Please help me, I'm not a programmer but I want learn how to do this kind of stuff.
Thank you very much for give me some advices
Comments
Comment #1
DamienMcKennaFYI it might be easier to create a new set of defaults for that content type and then just build a token to insert the data you want?
Comment #2
MXTI've found this working solution for now:
DamienMcKenna: thank you, I'll go to explore your suggestion with token (despite I absolutely don't know where to start..)