Modifying the User Account View template
This modification will customize the user’s “My Account” page to look like this. This modification utilizes the node_profile_bonus module, so make sure it is installed and enabled. The template file is located in your theme subdirectory. If the functions described below do not exist in the template.php, go ahead and create them (cut-n-paste).
function _phptemplate_variables($hook, $vars) {
if ($hook == page) {
if (arg(0) == user) {
$vars['tabs'] = str_replace('Edit</a>', 'Edit Account</a>', $vars['tabs']);
}
/* Disable the secondary tabs as well */
/*
if ($secondary = menu_secondary_local_tasks()) {
$output = '<span class="clear"></span>';
$output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
$vars['tabs2'] = $output;
}
*/
return $vars;
}
return array();
}
// Override the entire user account view page to not show the
// categories or to seperate items into divs. Note that this is
// set up to still show everything that is thrown on this page.
// Getting rid of non-nodeprofile sections is done in the node_profile_bonus
// module by unsetting them but could also be done here by conditionally
// printing them to begin with.
function phptemplate_nodeprofile_display_box($element, $content) {
$head = isset($element['#title']) ? '<h2 class="nodeprofile-title">'. check_plain($element['#title']) .'</h2>' : '';
return $content;
}
/**
* Catch the theme_profile_profile function, and redirect through the template api
*/
function phptemplate_user_profile($account, $fields) {
// 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 */
foreach ($fields as $category => $items) {
foreach ($items as $item) {
$output .= $item['value'] ;
}
}
// Returning nothing from this function causes the entire page to whitescreen,
// so lets put something in by default. A better idea might be to load up some
// sort of standard thing that has the views and just not the profile fields
if (empty($output)) {
$output = "This user has not filled out a user profile.";
}
return $output;
}
Theme Modifications
By default in drupal, nodes display the time/date of node submission. Having this on the user profile page looks like kinda goofy. There are two ways to customize the output.
- Turn off the display of post information in the theme general settings or
- Customize the content output using node-uprofile.tpl.php
Theming the user profile display page
- Create a file called node-uprofile.tpl.php in your theme directory and add this code.
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print
' node-unpublished'; } ?>">
<?php if ($page == 0): ?>
<h2>
<a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a>
</h2>
<?php endif;
if ($page == 1): // if node is being displayed as a full node
?>
<div class="content">
<?php print $content ?>
</div>
<div class="clear-block clear">
</div>
<?php
endif;
?>
</div>
Theming the user profile edit page
Michelle’s write up provides instructions on themeing and customizing the user profile edit page. However, I have found that if I use the node-uprofile-edit.tpl.php, updates to the profile pages by users was causing the node published status to be set to be Unpublished. So I am not using this edit template but simply mention here for the sake of completeness.
At this point, each user can create a profile page by visiting My Account -> Edit Profile. Next, we will setup the Active Directory integration so that the user’s contact information is integrated into the profile page.












Great tutorial! Thanks for sharing. I was able to successfully duplicate your implementation for my needs with a few exceptions:
1) when creating the AD block view, I do not have an option to add the user ID field from the users as shown in your view. I do have, however, a user ID field from the usernode table.
2) I cannot seem to get the block to display as yours does, which might be due to the above.
Would you happen to know how I can fix these two issues?
Thanks again!!
Oh … and … where does the account_url come into play? I just noticed that if I try to edit a profile of a user when logged in as admin, it saves the node as admin profile (I assume because of the authoring info).
Nikkol
The account_url is used to provide links in the Searchable list of user profiles (Employee Directory).
Nikkol
Regarding your question about the AD block view, can you specify which step you are having this problem ? Did you try to import the code for the AD Block ?
[...] read more | digg story [...]
Thanks for the tutorial. I’m a little confused – is the data in active directory supposed to show up in the Employee Directory view automatically, or would each user have to create a uprofile first? I’m trying to display a phone book populated by AD info. Any advice appreciated. Thanks!
The AD data should show up as soon as the profile page is created. It pulls it automatically from Active Directory.
[...] Drupal Profiles with Active Directory Integration · Rajeev Karamchedu [...]
Can this be updated for Drupal 6?
Unfortunately, no. I do not have access to Drupal (nor Active Directory, for that matter).