0

I have overridden the user profile template using Panels module and want to render this overridden user profile in one of my custom module.

Actually I wanted to show "About Author", tab besides the "View" tab of article, which when clicked, will show overridden user profile.

For that I have created menu entry as follows:

function custom_menu() {
   $items = array();

    $items['node/%node/author'] = array(
        'title' => 'About Author',
        'page callback' => 'get_node_author',
        'page arguments' => array(1),
        'access callback' => TRUE,
        'type' => MENU_LOCAL_TASK,
    );

    return $items;
}

My function is as follows:

function get_node_author($node = NULL) {
    $account = user_load($node->uid);
    $account_view = user_view($account);
    return drupal_render($account_view);
}

But it is loading user profile in normal format and not the one which is customized using panels.

Any suggestion how can I achieve this?

  • Never tried, so I don't know. Out of curiosity, why are you doing this from a custom function anyway? Having built a large number of sites with Panels, I find the idea odd, and I'm wondering if you really should be solving this differently. – Letharion Mar 13 '13 at 7:03
  • I just wanted to create one MENU_LOCAL_TASK (because it must be tab besides view, edit etc.) entry for node that shows customized author profile. Do you have any suggestion ? – Kalpesh Patel Mar 13 '13 at 7:07
  • Why not just re-create the user override you now have as a custom page in Panels? You can handle the menu directly from there. – Letharion Mar 13 '13 at 7:12
  • Ok let me try out. – Kalpesh Patel Mar 13 '13 at 7:16
  • Ok, posted as an answer. – Letharion Mar 13 '13 at 7:21
2

I suggest you don't create a menu hook at all.

Just implement your desired layout in a custom panels page instead, and you can control the menu from there.

  • Hey, thanks it is working, one last thing, how can I create tab menu from it. – Kalpesh Patel Mar 13 '13 at 7:41
  • Got it, I selected menu tab. – Kalpesh Patel Mar 13 '13 at 7:42
  • Well, that was easy ;) Glad I could help. :) – Letharion Mar 13 '13 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.