Skip to main content
added 7 characters in body
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

I have created a question node type using CCK and would like to show all of the questions which users create on a tab on their profile page.

The way I have done this feels a little indirect. I have:

  1. Created a view which lists all of a user's questions and made a block to display it.
  2. Configured the block so that it only displays on the right path ("user/*/questions").
  3. Created an entry in hook_menu for this path. Used a page callback which calls a function which creates an empty page (see below).

Is there a more direct way to do this by, e.g., attaching the view directly to the profile page?

The code in hook_menuhook_menu() is:

$items['user/%/questions'] = array(
  'title'            => 'Your Questions',
  'description'      => 'User Questions',
  'page callback' => 'answers_blank_page',
  'access arguments'  => array('create question content'),
  'type'     => MENU_LOCAL_TASK,
  'weight' => 9,
);

The page callback is simply:

function answers_blank_page () {
  return '';
}

I have created a question node type using CCK and would like to show all of the questions which users create on a tab on their profile page.

The way I have done this feels a little indirect. I have:

  1. Created a view which lists all of a user's questions and made a block to display it
  2. Configured the block so that it only displays on the right path ("user/*/questions")
  3. Created an entry in hook_menu for this path. Used a page callback which calls a function which creates an empty page (see below)

Is there a more direct way to do this by, e.g., attaching the view directly to the profile page?

The code in hook_menu is:

$items['user/%/questions'] = array(
  'title'            => 'Your Questions',
  'description'      => 'User Questions',
  'page callback' => 'answers_blank_page',
  'access arguments'  => array('create question content'),
  'type'     => MENU_LOCAL_TASK,
  'weight' => 9,
);

The page callback is simply:

function answers_blank_page () {
  return '';
}

I have created a question node type using CCK and would like to show all of the questions which users create on a tab on their profile page.

The way I have done this feels a little indirect. I have:

  1. Created a view which lists all of a user's questions and made a block to display it.
  2. Configured the block so that it only displays on the right path ("user/*/questions").
  3. Created an entry in hook_menu for this path. Used a page callback which calls a function which creates an empty page (see below).

Is there a more direct way to do this by, e.g., attaching the view directly to the profile page?

The code in hook_menu() is:

$items['user/%/questions'] = array(
  'title'            => 'Your Questions',
  'description'      => 'User Questions',
  'page callback' => 'answers_blank_page',
  'access arguments'  => array('create question content'),
  'type'     => MENU_LOCAL_TASK,
  'weight' => 9,
);

The page callback is simply:

function answers_blank_page () {
  return '';
}
Tweeted twitter.com/#!/StackDrupal/status/74719963755196416
Source Link
chipcleary
  • 593
  • 5
  • 13

Is there a better way to make a user profile tab using a view?

I have created a question node type using CCK and would like to show all of the questions which users create on a tab on their profile page.

The way I have done this feels a little indirect. I have:

  1. Created a view which lists all of a user's questions and made a block to display it
  2. Configured the block so that it only displays on the right path ("user/*/questions")
  3. Created an entry in hook_menu for this path. Used a page callback which calls a function which creates an empty page (see below)

Is there a more direct way to do this by, e.g., attaching the view directly to the profile page?

The code in hook_menu is:

$items['user/%/questions'] = array(
  'title'            => 'Your Questions',
  'description'      => 'User Questions',
  'page callback' => 'answers_blank_page',
  'access arguments'  => array('create question content'),
  'type'     => MENU_LOCAL_TASK,
  'weight' => 9,
);

The page callback is simply:

function answers_blank_page () {
  return '';
}