Customising the user profile layout
The PHP Snippets below are intended for use within a customised USER PROFILE page that simply enables you to "pull" specific content from your drupal database specific to a particular user and display it in the way you want.
They are intended for use with a phptemplate based theme and for Drupal site developers who do not have php programming knowledge but want to push out the boundaries of user profile pages and control precisely how they look.
Simple step-by-step instructions are provided.
The concept
Drupal is an extremely powerful tool for building online communities, in particular, allowing users to submit their own content to a community hub. A good illustration of this working well online might be the World famous myspace.com site, where bands/artists are able to submit content into their own page.
Drupal has all the tools available to create your own myspace.com style community hub.
These snippets are intended as a mini-repository and as an aid for site designers without php programming skills to create sophisticated User Profile Pages for members of their community.
Customised User Profile Pages maybe applied to many applications. myspace.com is primarily a site for artists & bands, but, similar techniques could be used for other applications such as a rzye.com (Drupal powered community hub) style professional networking hub or terminus1525 (Drupal powered community hub) for studios.
Getting Started
Step 1 is to override the default User Profile page layout by uploading the special template.php file to your active theme folder.
<?php
/**
* Catch the theme_user_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));
}
?>If you already have a template.php file in your active theme folder, simply add the above to the existing template.php file and upload it.
Step 2 is to create your customised user_profile.tpl.php file and upload that to your active theme folder.
If you're starting from scratch, simply open notepad.exe or a similar text editor and paste in the snippets linked below to build your custom user profile page. Save it with the user_profile.tpl.php filename and upload it to your theme folder along with the template.php file.
Once you have got started with your first user_profile.tpl.php file, you can experiment with adding in more snippets or including HTML layout controls to get a feel for the flexibility this allows.
How to use these snippets
Simply copy and paste these snippets into your user_profile.tpl.php file and upload it to your active theme folder.
It's recommended that you test your customised user_profile.tpl.php file on a test installation before adding to a live site and you can disable them at any time by removing your changes i.e. the template.php changes AND the user_profile.tpl.php file. The PHP TEMPLATE engine needs both of these files for the overrides to work.
Adding new snippets
Simply click on the ADD NEW CHILD PAGE link below and create a new handbook page. Include any dependencies, such as which version of Drupal you have tested the snippet with or extra modules that need to be enabled for the snippet to work.
PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.
