- Issue created by @nessthehero
- πΊπΈUnited States DamienMcKenna NH, USA
Try using hook_metatag_entity_type_is_supported_alter(), please let us know if that works.
- πΊπΈUnited States nessthehero
@damienmckenna Do you have more info on that hook? I can't find it documented anywhere and I can't pause inside it with XDebug.
Just updated my local metatag to 2.1.0 as well.
- πΊπΈUnited States DamienMcKenna NH, USA
Oh, sorry, that's from D7.
You could try hook_metatag_route_entity(), please see if the current route is your custom entity type and return NULL.
- πΊπΈUnited States nessthehero
Unfortunately I'm not seeing any results from this. Returning null doesn't change any of the global metatags that are pulled into the page.
- πΊπΈUnited States DamienMcKenna NH, USA
It might be necessary to add a new hook that allows disabling Metatag entirely for a route.. or maybe extend Metatag Custom Routes to allow this as an option?
- πΊπΈUnited States nessthehero
Just to give a sampling of what I've tried so far:
function cmu_expertfile_metatag_route_entity() { if (strpos(\Drupal::routeMatch()->getRouteName(), 'cmu_expertfile') !== FALSE) { return []; } } function cmu_expertfile_metatags_alter(array &$metatags, array $context) { $metatags['og:description'] = '-2- Beep boop website stuff'; } function cmu_expertfile_metatags_attachments_alter(array &$attachments) { if (isset($attachments['#attached']['html_head'])) { foreach ($attachments['#attached']['html_head'] as $key => &$attachment) { if ($attachment[1] == 'og:description') { $attachments['#attached']['html_head'][$key][0]['#attributes']['content'] = 'Beep boop website stuff'; } } } } function cmu_expertfile_page_attachments_alter(array &$page) { if (!empty($page['#attached']['html_head'])) { foreach ($page['#attached']['html_head'] as &$attachment) { if ($attachment[1] == 'og:description') { $attachment[0]['#attributes']['content'] = 'Beep boop website stuff'; } } } }
I'm just trying to get literally anything to show up in the Global og:description meta tag from my custom module, and I can't override it this way.
I would expect that adding a metatag to html_head would at some point reduce any duplicates, deferring to the most recent attachment. If the metatag module is set up to add Global metatags last, I would also then expect that module to detect existing items first.
- πΊπΈUnited States nessthehero
It might be necessary to add a new hook that allows disabling Metatag entirely for a route.. or maybe extend Metatag Custom Routes to allow this as an option?
Yes, this sounds promising. Happy to help in any way I can.
- πΊπΈUnited States DamienMcKenna NH, USA
Alternatively, have you considered using Metatag Custom Routes to control the meta tags you want to show?
- πΊπΈUnited States nessthehero
That module is too experimental for our use case. I also feel like what I'm trying to do should work out of principle. It doesn't seem that far out there to just be able to override things in PHP.
- πΊπΈUnited States DamienMcKenna NH, USA
Take a look at β¨ Add placeholder to clear / unset inherited value Closed: duplicate , it might help.