function fb_instant_articles_page_attachments_alter in Facebook Instant Articles 8
Same name and namespace in other branches
- 8.2 fb_instant_articles.module \fb_instant_articles_page_attachments_alter()
- 3.x fb_instant_articles.module \fb_instant_articles_page_attachments_alter()
Implements hook_page_attachments_alter
Parameters
array $page: page render array
File
- ./
fb_instant_articles.module, line 33 - Contains fb_instant_articles.module..
Code
function fb_instant_articles_page_attachments_alter(array &$page) {
/**
* @var Drupal\Core\Config\ImmutableConfig $config
* The config entity for fb_instant_articles
*/
$config = \Drupal::config('fb_instant_articles.adminconfig');
if ($config instanceof Drupal\Core\Config\ImmutableConfig) {
/**
* If there is a stored configuration for the FIA Application ID
* then add a page <meta> tag to all pages showing the id
*
* <meta property="fb:pages" content="{id goes here}" />
*/
$fia_pagesid = $config
->get('pagesid');
if ($fia_pagesid != '') {
$meta_fia_pagesid = [
'#tag' => 'meta',
'#attributes' => [
'property' => 'fb:pages',
'content' => $fia_pagesid,
],
];
$page['#attached']['html_head'][] = [
$meta_fia_pagesid,
'fia_pagesid',
];
}
}
}