I am trying to add a menu tab on the user profile page with the # of blog posts someone has made.
Ex: Blogs (3)
/**
* Implementation of hook_menu
*/
function menutab_followers_menu() {
$view = views_get_view( 'blogs_written' );
$view->execute();
$count = count( $view->result );
$items['user/%user/blogs'] = array(
'title' => t('Blogs @count', array('@count' => $count)),
'page callback' => 'menutab_blogs_linkspage',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
);
return $items;
}
For some reason it won't use the contextual filter. It displays Blogs (0) instead of Blogs (3) I have it set the views contextual filter to raw value, path 2, and use url alias. Ex: mywebsite.com/users/admin
If I insert the view in the profile page using Display Suite, it works fine, it displays all 3 items on the page. Also, if I set the contextual filter to a fix value and type "Admin" it displays Blogs (3) on the menu tab. But I don't want that, since it would display that to every user.