Fix for Load a Node on the user Page

  1. function mymodule_menu() {
  2. $items['user/%user_uid_optional/surf'] = array(
  3.           'title' => 'Info',
  4.           'page callback' => 'load_info',
  5.           'page arguments' => array(1),
  6.           'access callback' => TRUE,
  7.           'type' => MENU_LOCAL_TASK,
  8.           );
  9.        
  10.     return $items;
  11. }
  12.  
  13. /**
  14.  * Callback for 'Info'
  15.  * @return
  16.  */
  17.  
  18. function load_info($uid) {
  19.         $query = "SELECT nid FROM {info} WHERE uid = %d"; //This node is unique. There is only one node per user.
  20.         $result = db_query($query, $uid);
  21.        
  22.         if($nid = db_fetch_object($result)) {
  23.                 $node = node_load(nid);
  24.         }
  25.         return info_view($node);
  26. }
  27.  
  28. /**
  29.  * Implements hook_view().
  30.  */
  31. function mymodule_view($node, $teaser = FALSE, $page = FALSE) {
  32.         $node = node_prepare($node, $teaser);//get it ready for display
  33.    
  34.     $node -> content['areas'] = array(
  35.           '#value' => theme('info_areas', $node),
  36.           '#weight' => 1
  37.         );
  38.        
  39.         return $node;
  40. }
  41.  
  42. /**
  43.  * Implements hook_theme().
  44.  */
  45.  
  46. function mymodule_theme() {
  47.         return array(
  48.           'info_areas' => array(
  49.             'arguments' => array('node')
  50.           )
  51.         );
  52. }
  53.  
  54. function theme_info_areas($node) {
  55.         $output = '<div class="info_areas">'.
  56.           check_markup($node->areas). '</div>';
  57.          
  58.         return $output;
  59. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.