function blog_node_links_alter in Blog 8.2
Same name and namespace in other branches
- 3.x blog.module \blog_node_links_alter()
Implements hook_node_links_alter().
File
- ./
blog.module, line 69 - Enables multi-user blogs.
Code
function blog_node_links_alter(array &$node_links, NodeInterface $entity, array &$context) {
if ($entity
->getEntityTypeId() == 'node' && $entity
->bundle() == 'blog_post' && $context['view_mode'] != 'rss') {
$links['blog_usernames_blog'] = [
'title' => t("@username's Blog", [
'@username' => $entity
->getOwner()
->getDisplayName(),
]),
'url' => Url::fromRoute('view.blog.blog_user_all', [
'arg_0' => $entity
->getOwnerId(),
]),
'attributes' => [
'title' => t("Read @username's latest blog entries.", [
'@username' => $entity
->getOwner()
->getDisplayName(),
]),
],
];
$node_links['usernames_blog'] = [
'#theme' => 'links__node__blog',
'#links' => $links,
'#attributes' => [
'class' => [
'links',
'inline',
],
],
];
}
}