I am using User:UID as an argument with the default to User ID for logged in User. Basic validation.

The paths for the pages are:
profile (no menu)
profile/%/blogs (default tab -> normal menu path)
profile/%/newsletter (menu path)

When I go to 'profile/1' - is shows the blog page with tabs for blog and newsletter (it's correct)

When I go to 'profile' it only shows the blog page, with no tabs for the other profile pages (I would like it to show the logged in user's blog page with a tabs for blog and newsletter)

How do I correct this? I noticed that profile.module also has a menu path to 'profile' - not sure if this is creating a conflict.

Comments

dawehner’s picture

profile/%/newsletter (menu path)

You would need here tab, too.

I guess thats everything, todo.

It would be cool if you would have read http://drupal.org/node/571990 :)

hellomobe’s picture

This is a tab - my apologies - I meant 'menu tab' not menu path. Sorry about that.

The paths for the pages are:
profile (no menu)
profile/%/blogs (default menu tab -> normal menu item)
profile/%/newsletter (menu tab)

A reminder, the tabs show fine when the argument is present, but doesn't work when the argument is not present, and should default back to the current logged in user.

dawehner’s picture

the you have to provide default argument in your view.

Its really good if you read the link above. There is explained, that you should export your view.

hellomobe’s picture

Please explain in more detail.

In my view, for each of the pages, I have the arguement User:ID -> Action to take if argument is not present: -> Provide default argument -> User ID from logged in user

$view = new view;
$view->name = 'profiles_example';
$view->description = 'profiles';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('arguments', array(
  'uid' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => '',
    'wildcard_substitution' => '',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'current_user',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'uid',
    'table' => 'users',
    'field' => 'uid',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
      '3' => 0,
      '5' => 0,
      '6' => 0,
      '10' => 0,
      '7' => 0,
      '11' => 0,
      '8' => 0,
      '9' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'webform' => 0,
      'image' => 0,
      'blog' => 0,
      'ad' => 0,
      'forum' => 0,
      'announcement' => 0,
      'company' => 0,
      'feed' => 0,
      'frontpage_promo' => 0,
      'group' => 0,
      'newsletter' => 0,
      'page' => 0,
      'profile' => 0,
      'property_listing' => 0,
      'property_list_feed' => 0,
      'story' => 0,
      'tenant_profile' => 0,
      'vendor_profile' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '5' => 0,
      '11' => 0,
      '2' => 0,
      '3' => 0,
      '6' => 0,
      '4' => 0,
      '10' => 0,
      '8' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_node_flag_name' => '*relationship*',
    'validate_argument_node_flag_test' => 'flaggable',
    'validate_argument_node_flag_id_type' => 'id',
    'validate_argument_user_flag_name' => '*relationship*',
    'validate_argument_user_flag_test' => 'flaggable',
    'validate_argument_user_flag_id_type' => 'id',
    'validate_argument_php' => '',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('empty_format', '2');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 1);
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
  'relationship' => 'none',
  'build_mode' => 'full',
  'links' => 1,
  'comments' => 1,
));
$handler = $view->new_display('page', 'Page: News', 'page_2');
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'newsletter' => 'newsletter',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('path', 'profile/%/newsletter');
$handler->override_option('menu', array(
  'type' => 'tab',
  'title' => 'Newsletter',
  'description' => '',
  'weight' => '0',
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
$handler = $view->new_display('page', 'Page', 'page_4');
$handler->override_option('fields', array(
  'body' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => 'This person has not completed his/her profile.',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'exclude' => 0,
    'id' => 'body',
    'table' => 'node_revisions',
    'field' => 'body',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'blog' => 'blog',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('row_plugin', 'fields');
$handler->override_option('row_options', array());
$handler->override_option('path', 'profile');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
$handler = $view->new_display('page', 'Page', 'page_5');
$handler->override_option('fields', array(
  'body' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => 'This person has not completed his/her profile.',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'exclude' => 0,
    'id' => 'body',
    'table' => 'node_revisions',
    'field' => 'body',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'blog' => 'blog',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('row_plugin', 'fields');
$handler->override_option('row_options', array());
$handler->override_option('path', 'profile/%/blogs');
$handler->override_option('menu', array(
  'type' => 'default tab',
  'title' => 'My Blogs',
  'description' => '',
  'weight' => '0',
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'normal',
  'title' => 'Profile',
  'description' => '',
  'weight' => '0',
));
merlinofchaos’s picture

Status: Active » Fixed

The problem here is how Drupal parses tabs. THe tabs live at profile/% which means they simply won't appear at profile/ at all. The easiest solution is to put a redirect at 'profile' to redirect to profile/XXX where XXX is the user's UID. You could do this with a bit of PHP code in the default options.

Make sure you do this only on a page display (you wouldn't want a block or something to accidentally redirect) and you might want your code to check $view->live_preview to ensure you don't redirect during preview. =)

Something along these lines in the provide default PHP code:

  global $user;
  if ($user->uid && empty($view->live_preview)) {
    drupal_goto('profile/' . $user->uid);
  }
hellomobe’s picture

merlinofchaos you worked the magic! Thank you - works great.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.