Displaying/Customizing content on user profile page.
Important Note: There's no more need to modify the user-profile.tpl.php file in the user module. If you have, you should revert back to the default file that orginally came with drupal.
The page we're talking about is user profile page ("My Account"). Currently the friend module injects it's own block information (ie. mini-fee, friends, mutual friends ...) and then wipes out the 'summary', 'user_picture' and og_groups (if installed). This results in only friend infromation blocks being display in the user profile view page.
What we're going to do is inject our own content as a friend block to be display on the user profile page.
First you'll need to tell Friend about your content. Refer to : Add your own custom content into the Friend permission list ... this will allow the owner of the info to control who sees the info.
Next you'll need to hook into the hook_friend($op,$source_id,$dest_id)
The $op to look for is : 'user_profile'
Other $op you can use are :
'remove' - friend has been removed
'insert' - friend has been added
'post_cork' - friend has been post a cork
'del_cork' - cork has been deleted
Here's how the Notice module injects its mini-feed block :
<?php
function notice_friend($op,$source_id,$dest_id,$variables=array()){
global $user;
switch($op){
case 'user_profile':
if (friendapi_has_access($user->uid,$dest_id,'notice_mini_feed') ||
$user->uid == $dest_id){
// is friend
$output = noticeapi_mini_feed($dest_id);
return array (
'id' => 'notice_mini_feed',
'title' => t('Mini-Feed'),
'weight' => 5,
'value' => $output,
);
};
break;
};
}
?>If you leave the 'title' index out then no title bar will be shown.
Customize Profile Block
There are two files you'll need to play around with.
friend/tpl/friend-user-profile.tpl.php - this file is where you'd customize the display of the blocks .. i.e. where and what order the blocks should be displayed.
Notice how our notice mini-feed is dislayed in the friend-user-profile.tpl.php file.
To customize the actual individual blocks. You'll need to modify the tpl/friend-user-block.tpl.php
The preprocess functions for both files are located in friend.theme.inc
