function template_preprocess_forward in Forward 4.x
Same name and namespace in other branches
- 8.3 forward.module \template_preprocess_forward()
- 8 forward.module \template_preprocess_forward()
- 8.2 forward.module \template_preprocess_forward()
- 6 forward.module \template_preprocess_forward()
- 7.3 forward.module \template_preprocess_forward()
- 7 forward.module \template_preprocess_forward()
- 7.2 forward.module \template_preprocess_forward()
- 4.0.x forward.module \template_preprocess_forward()
Implements template_preprocess_module().
File
- ./
forward.module, line 90 - Allows forwarding of entities by email.
Code
function template_preprocess_forward(&$variables) {
// Site info.
$url = 'internal:' . \Drupal::config('system.site')
->get('page.front');
$variables['site_url'] = Url::fromUri($url, [
'absolute' => TRUE,
]);
$variables['site_name'] = \Drupal::config('system.site')
->get('name');
// Read more link. Use a custom template to remove.
$variables['link'] = '';
$entity = $variables['entity'];
if ($entity && $entity
->access('view')) {
$variables['link'] = t('<a href="@entity-url">Read more about @entity-name</a>', [
'@entity-url' => $entity
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString(),
'@entity-name' => $entity
->label(),
]);
}
// Logo.
if (!empty($variables['settings']['forward_email_logo'])) {
$url = 'base:' . $variables['settings']['forward_email_logo'];
$url = Url::fromUri($url, [
'absolute' => TRUE,
])
->toString();
}
else {
$url = theme_get_setting('logo.url');
if (!UrlHelper::isExternal($url)) {
$url = Url::fromUri('base:/' . $url, [
'absolute' => TRUE,
])
->toString();
}
}
$variables['logo'] = [
'#markup' => '<img src="' . $url . '" />',
];
}