I'm customizing the user profile with the help of this code and putting in template.php. But when i login to site then nothing is displaythe blank screen come in front of me. But when i use the code after login and update the template.php user profile customize....then user profile works but other functionalities create problems...Plz help

The code below i'm using in template.php

function phptemplate_user_profile($user, $fields = array())
{

return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));

}

my user profile page is user_profile.tpl.php

Comments

carlmcdade’s picture

Can you post your template.php and the user_profile.tpl.php? To solve code problems you have to see the code ;)

Hiveminds Magazine | Drupal Developers Network

manmohanghai_mca’s picture

Ya template.php code is given below....

/**
 * Sets the body-tag class attribute.
 *
 * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
 */
function phptemplate_body_class($sidebar_left, $sidebar_right) {
  if ($sidebar_left != '' && $sidebar_right != '') {
    $class = 'sidebars';
  }
  else {
    if ($sidebar_left != '') {
      $class = 'sidebar-left';
    }
    if ($sidebar_right != '') {
      $class = 'sidebar-right';
    }
  }

  if (isset($class)) {
    print ' class="'. $class .'"';
  }
}
/**
 * Return a themed breadcrumb trail.
 *
 * @param $breadcrumb
 *   An array containing the breadcrumb links.
 * @return a string containing the breadcrumb output.
 */
function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
  }
}

/**
 * Allow themable wrapping of all comments.
 */
function phptemplate_comment_wrapper($content, $type = null) {
  static $node_type;
  if (isset($type)) $node_type = $type;

  if (!$content || $node_type == 'forum') {
    return '<div id="comments">'. $content . '</div>';
  }
  else {
    return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
  }
}

/**
 * Override or insert PHPTemplate variables into the templates.
 */
/*function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {

    if ($secondary = menu_secondary_local_tasks()) {
      $output = '<span class="clear"></span>';
      $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
      $vars['tabs2'] = $output;
    }

    // Hook into color.module
    if (module_exists('color')) {
      _color_page_alter($vars);
    }
    return $vars;
  }
  return array();
}*/

/**
 * Returns the rendered local tasks. The default implementation renders
 * them as tabs.
 *
 * @ingroup themeable
 */
function phptemplate_menu_local_tasks() {
  $output = '';

  if ($primary = menu_primary_local_tasks()) {
    $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
  }

  return $output;
}

/**
 * Override theme_links to include <span> in list.
 */
function phptemplate_linksnew($links, $attributes = array('class' => 'links')) {
  $output = '';

  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = '';

      // Automatically add a class to each link and also to each LI
      if (isset($link['attributes']) && isset($link['attributes']['class'])) {
        $link['attributes']['class'] .= ' ' . $key;
        $class = $key;
      }
      else {
        $link['attributes']['class'] = $key;
        $class = $key;
      }

      // Add first and last classes to the list of links to help out themers.
      $extra_class = '';
      if ($i == 1) {
        $extra_class .= 'first ';
      }
      if ($i == $num_links) {
        $extra_class .= 'last ';
      }
	  
	 
	  // Add class active to active li 
	  $current = '';
	  if (strstr($class, 'active')) {
	    $current = ' active';
	  }	

	  $output .= '<li class="'. $extra_class . $class . $current .'"><span>';
	  
	  // Is the title HTML?
      $html = isset($link['html']) && $link['html'];

      // Initialize fragment and query variables.
      $link['query'] = isset($link['query']) ? $link['query'] : NULL;
      $link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;

      if (isset($link['href'])) {
        $output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
      }
      else if ($link['title']) {
        //Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (!$html) {
          $link['title'] = check_plain($link['title']);
        }
        $output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
      }

      $i++;
      $output .= "</span></li>\n";
    }

    $output .= '</ul>';
  }

  return $output;
}
/**
* Catch the theme_profile_profile function, and redirect through the template api
*/

function phptemplate_user_profile($user, $fields = array()) {
// Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
// will be assigned within your template.
/* potential need for other code to extract field info */
	return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
}

and user_profile.tpl.php is here....

Name: if($user->profile_1){

print check_plain($user->profile_1);

}

Gender: if($user->profile_2){

print check_plain($user->profile_2);
}

   
		if($user->picture)
		{
			print theme('user_picture', $user);
		}
		else 
		{ 
			print '<img src="./files/user_pic/noPic.jpg" alt="This user has not posted a picture yet or whatelse" />';
		}
	

Developed By Hash Technologies Pvt Ltd.

tnanek’s picture

Well, as a module developer, I can give you some guidance anyway (I don't know the template files at all - I haven't worked on themes yet so I can't help with the code directly).

The white screen comes up when you have a syntax error in the PHP (could come up for other reasons, but thats the most probable one I've encountered). Its easiest to see where the error is by checking the PHP Error Logs on your server - each time a white screen is loaded, a new log entry is made, so check right after you load one and it should give you some guidance as to what the problem is - at minimum if it is a syntax error it will tell you what file the error is in and what line.

manmohanghai_mca’s picture

Ya i have gone through the error log i have found the error...

Cannot modify header information - headers already sent by (output started at
...\Duduang\themes\aberdeen\template.php:164)
in
..\www\Duduang\includes\common.inc on line 314.

but how to solve this...

manmohanghai_mca’s picture

Ya i have gone through the error log i have found the error...

Cannot modify header information - headers already sent by (output started at
...\Duduang\themes\aberdeen\template.php:164)
in
..\www\Duduang\includes\common.inc on line 314.

heine’s picture

print ' class="'. $class .'"';

Also, a terminal ?> followed by whitespace is a good candidate. Simply remove a terminal ?> from your files.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.

manmohanghai_mca’s picture

Thanx for ur suggetion it help me out of the mess...