Twitter Tab shouldn't be visible if user has not given his account informations
Starminder - April 29, 2009 - 16:53
| Project: | |
| Version: | 6.x-2.4 |
| Component: | User interface |
| Category: | task |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Module is setup, but there are no fields to enter account information on the Twitter Tab in my user account.

#1
I can confirm this problem. Uninstalled, reinstalled, tried dev version -- nothing changes.
#2
Are you looking at the "Twitter" tab or the "Twitter accounts" sub tab under "Edit"?
The main Twitter Tab is controlled by the tweets View, and will be empty if there are no Twitter status' imported.
#3
http://drupal.org/node/448676#comment-1587782 is the way to go.
The fact that the Twitter tab is shown even if the user has not given his Twitter account information is very irritating.
The Twitter Tab should not show up if the user has not given his account informations. Should we open another issue for that?
#4
Woah, this was irritating and should really be fixed.
#5
I hope no one minds that I've bumped this up to critical status. This (fantastic) module is basically useless as long as this bug remains.
I've got a company site with a global twitter account, but only employees can use it (of course). I don't want other site users (clients) looking at an empty Twitter tab on their profile pages wondering what that feature does. I assume that this is not an uncommon application of this module.
I'm still building right now, but I'm thinking of a hack at the theme layer (once I get around to it) to get rid of the tab (since I don't need it on any user's profile page, actually). I'll post it here if it works for me.
#6
Subscribing.
#7
Subscribing. It really surprised me when I saw this "bug". It confused me a little as I thought I set up something wrong.
#PS: Also the tab shouldn't be shown if the " Import Twitter statuses" is disabled. It doesn't make sense to disable importing the Twitter statuses and show a blank page.
#8
I was hoping to be able to get this out at the theme layer, but instead I had to do a very minor hack to the module. In "twitter.views_default.inc" at about line 135, I replaced this:
$handler = $view->new_display('page', 'Page', 'page');$handler->override_option('path', 'user/%/tweets');
$handler->override_option('menu', array(
'type' => 'tab',
'title' => 'Twitter',
'weight' => '1',
));
with this:
// this commented out section added a twitter tab to all user profile pages
// $handler = $view->new_display('page', 'Page', 'page');
// $handler->override_option('path', 'user/%/tweets');
// $handler->override_option('menu', array(
// 'type' => 'tab',
// 'title' => 'Twitter',
// 'weight' => '1',
// ));
This removes the twitter tab from all profile pages (it actually prevents views from defining the page) without modifying the remaining featureset of the module (at least as far as I use it).
This does the job for my purposes, but I suppose if you wanted to use a less draconian measure, you could put conditionals on the original section of code, restricting the display of the tab and/or creation of the page by uid or role. This might also be where this feature would be patched for a future version of the module (so it could be configured in the admin), but I don't know enough about drupal module programming to make this happen. Anyone care to take it on?
#9
Put in your hack but I still see Twitter tabs... some kind of cache flush required?
Edit: yup. Had to do a total cache flush.
#10
Subscribing
#11
+1 for this fix.
We are not planning to dish out Twitter privileges to hundreds of users due to scalability concerns, but we want staffers to be able to use this module. Hiding the Twitter tab is important.
#12
Subscribing, definitely would like to see this changed.
#13
I don't even plan to allow my staffers to use the module directly. I want it to be used for news updates during live coverage events, like a local high school football game. Yes, we're a community newspaper.
With that in mind, I decided to remove the tab all together in favor of people tweeting from their phones remotely with a change to my template.php file.
function themename_preprocess_page(&$vars) {
// Remove undesired local task tabs.
// This first example removes the Users tab from the Search page.
endless_news_removetab('Twitter', $vars);
}
function themename_removetab($label, &$vars) {
$tabs = explode("\n", $vars['tabs']);
$vars['tabs'] = '';
foreach ($tabs as $tab) {
if (strpos($tab, '>' . $label . '<') === FALSE) {
$vars['tabs'] .= $tab . "\n";
}
}
}
#14
Subscribing.
#15
+1 on hiding this tab for folks who are not using twitter.
#16
Subscribing
#17
Simple fix: Site Building > Views > scroll to 'Tweets' > hit 'Disable'
Thought I'd better post this before the next "suggestion" involved hacking core...
#18
Yeah you can disable the twitter view from views (which I did), but this issue is about hiding the tab only if the user hasn't entered any twitter info.
I did a similar hack for the FriendFeed module in drupal 5, but that hack doesn't work in drupal 6 (I'll work on it when I have more time): http://drupal.org/node/277826
It involved loading the user object (user_load) and checking for the existence of the setting (probably not optimal, but it worked at least). You could also just do an SQL query yourself, similar to what the user_load object does, but more lightweight: http://api.drupal.org/api/function/user_load/6
This is a common thing with other views (with tabs/menus) too, so it'd be nice as a general feature (conditional views?).
Or since menus & tabs already dynamically hide based on permissions, perhaps it could be connected to that somehow.
#19
Attached is a small patch that will cause the tab to display only if the user has permission to add a personal twitter account. Once patched, you'll have to clear your cache for the change to take effect.
#20
Hope I get the time to try this soon.....
Against which version is this patch?
#21
6.x-2.6
#22
I updated my friendfeed patch to work for drupal 6, if you want to adapt it to the twitter module. It hides the menu tab if the user has not entered any friendfeed info in their account.
The key part is the menu 'access callback'. Add that to wherever the twitter menu tab is being created (in the menu hook).
function _friendfeed_user_tab_access($account) {
return user_access('view friendfeeds') &&
!empty($account->friendfeed_username) &&
!empty($account->friendfeed_key);
}
function friendfeed_menu() {
return array(
'user/%user/friendfeed' => array(
'title' => 'FriendFeed',
'description' => 'View FriendFeed status.',
'page callback' => 'friendfeed_user_view',
'page arguments' => array(1),
'access callback' => '_friendfeed_user_tab_access',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
),
);
}
#23
Subscribing
I'd love to see this fix in the module and not just a patch!
Sounds like many people have the same issue with only wanting to allow a subset of users to have twitter accounts!
#24
thank you to garethsprice, you saved me a lot of time and trouble... your solution was all i needed for my site.
#25
Thanks "garethsprice" ..
#26
garethsprice's solution works, but only if you don't actually want your tweets to be displayed somewhere.
Here's how I solved the problem:
1) Go to: admin/build/views/list
2) Edit the "Tweets" view
3) Select "User page"
4) Under "Page settings", change the "Menu" setting to "No menu"
Worked like a charm!