Adding layout and content to the default user profile theme
Last modified: August 23, 2009 - 21:14
description
The following snippet is essentially the default theme layout for a user profile (Drupal 5.x). You can use this to add content to the default, for example.
Thanks to Chrisivens for sharing the snippet.
instructions
- In a text editor paste the following snippet into your user_profile.tpl.php file
(For instructions on how to get started with your own custom user profile layout click through to the Customising the user profile layout handbook page.) - Upload your edited user_profile.tpl.php to your active theme folder
<?php
/**
* This is the default theme layout for user profiles (Drupal 5.x)
* Add more content or change layout to suit.
* For use in a custom user_profile.tpl.php file.
*/
foreach($fields as $category => $items) {
if(strlen($category) > 0) {
?><h2 class="title"><?php print check_plain($category) ?></h2>
<?php } ?>
<dl>
<?php
foreach($items as $item) {
if(isset($item['title'])) {
?><dt class="<?php print $item['class']; ?>"><?php print $item['title']; ?></dt>
<?php } ?>
<dd class="<?php print $item['class']; ?>"><?php print $item['value']; ?></dd>
<?php } ?>
</dl>
<?php } ?>An alternative layout would be:
<?php
$author = user_load(array('uid' => arg(1)));
$output = '<div class="profile">';
$output .= '<div class="picture">';
$output .= theme_image($author->picture);
$output .= '</div>';
foreach ($fields as $category => $items) {
if (strlen($category) > 0) {
$output .= '<h2 class="title">'. check_plain($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;
?>
Will this work in D6?
What if anything would I change? Thanks.