On this page
function blog_menu_local_tasks_alter
blog_menu_local_tasks_alter(&$data, $router_item, $root_path)
Implements hook_menu_local_tasks_alter().
File
- modules/blog/blog.module, line 140
- Enables multi-user blogs.
Code
function blog_menu_local_tasks_alter(&$data, $router_item, $root_path) {
global $user;
// Add action link to 'node/add/blog' on 'blog' page.
if ($root_path == 'blog') {
$item = menu_get_item('node/add/blog');
if ($item['access']) {
$item['title'] = t('Create new blog entry');
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
}
// Provide a helper action link to the author on the 'blog/%' page.
elseif ($root_path == 'blog/%' && isset($router_item['page_arguments'][0]->uid) && $router_item['page_arguments'][0]->uid == $user->uid) {
$data['actions']['output']['blog'] = array(
'#theme' => 'menu_local_action',
);
if (user_access('create blog content')) {
$data['actions']['output']['blog']['#link']['title'] = t('Post new blog entry.');
$data['actions']['output']['blog']['#link']['href'] = 'node/add/blog';
}
else {
$data['actions']['output']['blog']['#link']['title'] = t('You are not allowed to post a new blog entry.');
}
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!blog!blog.module/function/blog_menu_local_tasks_alter/7.x