Hello, newbie question here.

I would like to customize the user profile page, but maintain information added by other modules.

I have figured out how to customize the user profile page, by following the instructions here for creating a custom user_profile.tpl.php file: http://drupal.org/node/35728

However, when I create a custom user_profile.tpl.php file, I lose the information previously added by other modules. For example, the lm_paypal_subscriptions module has a function lm_paypal_subscriptions_user() which adds the user's list of subscriptions to the user profile page. After creating my custom user_profile.tpl.php file, the list of subscriptions no longer appears on the user profile page.

Can anyone give me a pointer on what I need to do to maintain info added by other modules to the user profile page?

Thanks very much!

P.S. Here is the lm_paypal_subscriptions_user() function:

/**
 * Implementation of hook_user().
 */
function lm_paypal_subscriptions_user($op, &$edit, &$account, $category = NULL) { 
  _lm_paypal_subscriptions_ini();
  global $_lm_paypal_debug;
  global $user;

  // TODO: On deleting a user issue a cancel on any subscriptions
  // obviously not on PayPal (can't!) just on here.

  // In the "my account" view area show any role subscriptions
  // but only for admin looking at other users or the user themself
  
  if ($op == 'view' && (user_access('administer lm_paypal') || $user->uid == $account->uid)) {
    $output = lm_paypal_subscribe(null, 32, '', null, $account); 
    $sitems [] = array(
      'title' => '',
      'value' => $output);
    $ret_subs = array(t('Subscriptions') => $sitems); 

    return $ret_subs;
  }
}

Comments

aaronmm’s picture

Hey,

We would like to add also the options from the modules etc..
Can someone help us out please?

Thanks a lot

kobnim’s picture

For other newbies, here's the solution I came up with...

My first suggestion is to read about themes and in particular, overriding theme functions.
I found these sites especially helpful:
http://www.nicklewis.org/node/841
http://www.nicklewis.org/node/842
http://drupal.org/node/16011

And I found the following book especially good, which you can purchase online as an e-book:
"Drupal Pro Development" by VanDyk and Westgate
Worth its weight in gold. The chapter on theming gives an excellent conceptual overview.

Here's how I wanted to customize the use profile page:
a) customize the contact info.
b) delete the "History" section, which says how long the user has been a member of the site.
c) keep everything else, eg the list of newsletter subscriptions created by the simplenews module.

Following the instructions here: http://drupal.org/node/16011, I first added the following to template.php:

function phptemplate_user_profile($user, $fields = array()) {
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
}

Then I cloned the theme_user_profile($account, $fields) function found in user.module, to create my custom user_profile.tpl.php as shown below:


<!-- display my custom version of the contact info: -->

<div class="profile">
	<h2 class="title">Contact Info</h2>
	<br>
	<div class="fields"><?php print check_plain($user->contact_first); ?> <?php print check_plain($user->contact_last); ?></div>
	<div class="fields"><?php print check_plain($user->contact_street); ?> -- <?php print check_plain($user->contact_city); ?>, <?php print check_plain($user->contact_state); ?> -- <?php print check_plain($user->contact_zip); ?></div>
	<div class="fields"><?php print check_plain($user->contact_phone); ?></div>
</div>
<br>
<hr>
<br>

<!-- Here is the cloned theme_user_profile() function, customized to suppress "Contact Info" and "History"  -->

<?php
  $output = '<div class="profile">';
  $output .= theme('user_picture', $user);
  foreach ($fields as $category => $items) {
  	if ($category!="Contact Info" && $category!="History"){ 
		if (strlen($category) > 0) {
		  $output .= '<h2 class="title">'. $category .'</h2>';
		}
		$output .= '<dl>';
		foreach ($items as $item) {
			  if (isset($item['title'])) {
				$output .= '<dt class="'. $item['class'] .'">'. $item['title'] .'</dt>';
			  }
			  $output .= '<dd class="'. $item['class'] .'">'. $item['value'] .'</dd>';
		  }
		$output .= '</dl>';
	}
  }
  $output .= '</div>';
  print $output;

Hope that helps. Good luck!
-- Mindy