Posted by dnorthcott on June 12, 2008 at 7:19pm
I have found many posts on how to remove tabs in druapl 5.x and lower, but how would i remove the 'view' tab in drupal 6.x?
cheers
I have found many posts on how to remove tabs in druapl 5.x and lower, but how would i remove the 'view' tab in drupal 6.x?
cheers
Comments
anyone? been searching
anyone? been searching forever to find a drupal 6 solution
If you have found what I
If you have found what I have found, it still works for d6 for me:)
love, light n laughter
blogid.net
love, light n laughter
geez.
c'mon.
I was looking for the same
I was looking for the same and I found a solution. I post it here just in case someone else needs it too.
With Drupal 6 hook_menu_alter (http://api.drupal.org/api/function/hook_menu_alter/6) you can disable the callback for view tab:
<?php
function mymodule_menu_alter(&$items) {
$items['user/%user/view']['access callback'] = FALSE;
}
?>
And then you can override user default tab for using your own with hook_menu:
<?php
function mymodule_menu(){
$items['user/%user_uid_optional'] = array(
'title' => 'My account',
'title callback' => 'user_page_title',
'title arguments' => array(1),
'page callback' => 'mymodule_callback',
'page arguments' => array(1),
'access callback' => 'user_view_access',
'access arguments' => array(1),
'parent' => '',
);
$items['mymodule-url'] = array(
'title' => t('Custom Title'),
'page callback' => 'mymodule_callback',
'page arguments' => array(1),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
}
?>
I have been trying to do this
I have been trying to do this for weeks and so far the above has gotten me the furthest. I have successfully removed the view tab, but I can't get it to redirect the user. Could you tell me how I would forward the user to user/%user/edit ? It would be greatly appreciated.
I hid both view and edit tabs
I hid both view and edit tabs with css and then redirected users from user/* to user/*/edit.
in the theme's style.css:
.logged-in.page-user .tabs {
display: none;
}
in the custom module:
create redirectprofile folder in sites/all/modules and copy these two files
redirectprofile.info
; $Id$
name = Redirect profile
description = Redirect users from user/* to user/*/edit.
core = 6.x
version = 6.x-1.0
redirectprofile.module
<?php
// Redirect users from user/* to user/*/edit.
function redirectprofile_user ($op, &$edit, &$account, $category = NULL) {
// Redirect user from user/* to user/*/edit
if ($op == "view" && arg(0) == "user") {
// Redirect user
drupal_goto('user/' . arg(1) . '/edit');
}
// OPTIONAL -- Change breadcrumb from Home > My account (with link) to Home > My account (without link)
if ($op == "load" && arg(0) == "user") {
$links = array(
l('Home', 'node'),
'My account'
);
drupal_set_breadcrumb($links);
}
}
?>
a concern
This works good. I tried your code. Thanks for that. I have a concern. I want to access other user profiles. So I am looking at something like, When the logged in user clicks on 'My Account' he has to be redirected to user->edit page. When the same user clicks on some other username, then he should be able to see the other users profile. How can this be done?
Thanks,
Betty
replace w/ <?phpfunction
replace w/
<?php
function redirectprofile_user ($op, &$edit, &$account, $category = NULL) {
// Redirect user from user/* to user/*/edit
global $user;
$uid = $user->uid;
if ($op == "view" && arg(0) == "user" && arg(1) == $uid) {
// Redirect user
drupal_goto('user/' . arg(1) . '/edit');
}
?>
not removing View tab
This is not removing the View tab from 'My Accounts' page. I added the class you said in my style.css but it is not working. Any reasons?
perhaps a simple solution?
i just created a page-user.tpl.php and removed the tabs php? seems to work fine?
Geez, this post is forgotten,
Geez, this post is forgotten, sorry. When I can find the source, I'll surely place it here. So here is what I have found and done, it's done through template layer:
Create a function in your template.php:
function yourthemename_remove_tab($label, &$vars) {
$tabs = explode("\n", $vars['tabs']);
$vars['tabs'] = '';
foreach($tabs as $tab) {
if(strpos($tab, '>'. $label .'<') === FALSE) {
$vars['tabs'] .= $tab . "\n";
}
}
}
Then inside your preprocess_page, create one if you don't have it:
function yourthemename_preprocess_page(&$vars, $hook) {Place the removal code with conditions as you please:
//Add specific condition, perhaps on user pages, so gives arg(0) == 'user', or node pages, arg(0) == 'node' , or hit em all except for adminif (!$is_admin) {
yourthemename_remove_tab('View', &$vars);
yourthemename_remove_tab('Edit', &$vars);
//you can add any other tab to remove here, such as "Request new password", etc.
}
Perhaps there is a better solution, such as module solution above.
@Andrew Jamieson, removing the tabs directly from page.tpl will simply remove them even from admin. So be careful :)
love, light n laughter
I got it to work with this
I got it to work with this
//Add specific condition, perhaps on user pages, so gives arg(0) == 'user', or node pages, arg(0) == 'node' , or hit em all except for adminif (!$is_admin) {
yourthemename_remove_tab('View', $vars);
yourthemename_remove_tab('Edit', $vars);
//you can add any other tab to remove here, such as "Request new password", etc.
}
I don't know why, but I would get an error displayed at the top of the page if I used the code above, I removed the & and the error went away.
subcribing.
subcribing.
All possible solutions in one
All possible solutions in one place
http://drupal.org/node/68792
------
GiorgosK
Geoland Web development / web marketing
Media Temple Special Offer Codes