X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fmodules%2Fcontrib%2Fmetatag%2Fmetatag.api.php;fp=web%2Fmodules%2Fcontrib%2Fmetatag%2Fmetatag.api.php;h=cd2ad01d86c67603530865e3ede547a26e0cb774;hb=059867c3f96750652c80f39e44c442a58c2549ee;hp=cbdee9ed7000422c5ea2d36850487658fe572eb2;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2;p=yaffs-website diff --git a/web/modules/contrib/metatag/metatag.api.php b/web/modules/contrib/metatag/metatag.api.php index cbdee9ed7..cd2ad01d8 100644 --- a/web/modules/contrib/metatag/metatag.api.php +++ b/web/modules/contrib/metatag/metatag.api.php @@ -31,11 +31,29 @@ function hook_metatag_route_entity(\Drupal\Core\Routing\RouteMatchInterface $rou * @param array $metatags * The special meta tags to be added to the page. * @param array $context - * The context, containing the entity used for token replacements. + * The context for the current meta tags being generated. Will contain the + * following: + * 'entity' - The entity being processed; passed by reference. */ -function hook_metatags_alter(array &$metatags, array $context) { +function hook_metatags_alter(array &$metatags, array &$context) { // Exclude meta tags on frontpage. if (\Drupal::service('path.matcher')->isFrontPage()) { $metatags = NULL; } } + +/** + * Alter the meta tags for any page prior to page attachment. + * + * @param array $metatag_attachments + * An array of metatag objects to be attached to the current page. + */ +function hook_metatags_attachments_alter(array &$metatag_attachments) { + if (\Drupal::service('path.matcher')->isFrontPage() && \Drupal::currentUser()->isAnonymous()) { + foreach ($metatag_attachments['#attached']['html_head'] as $id => $attachment) { + if ($attachment[1] == 'title') { + $metatag_attachments['#attached']['html_head'][$id][0]['#attributes']['content'] = 'Front Page Title for Anonymous Users'; + } + } + } +}