Skip navigation
Help

profile-block.tpl.php

  1. drupal
    1. 6 drupal/modules/profile/profile-block.tpl.php
    2. 7 drupal/modules/profile/profile-block.tpl.php

Default theme implementation for displaying a users profile within a block. It only shows in relation to a node displayed as a full page.

Available variables:

  • $user_picture: Image configured for the account linking to the users page.
  • $profile: Keyed array of all profile fields that have a value.

Each $field in $profile contains:

  • $field->title: Title of the profile field.
  • $field->value: Value of the profile field.
  • $field->type: Type of the profile field, i.e., checkbox, textfield, textarea, selection, list, url or date.

Since $profile is keyed, a direct print of the field is possible. Not all accounts may have a value for a profile so do a check first. If a field of "last_name" was set for the site, the following can be used.

<?php if (isset($profile['last_name'])): ?> <div class="field last-name"> <?php print $profile['last_name']->title; ?>:<br /> <?php print $profile['last_name']->value; ?> </div> <?php endif; ?>

See also

template_preprocess_profile_block()

1 theme call to profile-block.tpl.php

File

drupal/modules/profile/profile-block.tpl.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Default theme implementation for displaying a users profile within a
  5. * block. It only shows in relation to a node displayed as a full page.
  6. *
  7. * Available variables:
  8. * - $user_picture: Image configured for the account linking to the users page.
  9. * - $profile: Keyed array of all profile fields that have a value.
  10. *
  11. * Each $field in $profile contains:
  12. * - $field->title: Title of the profile field.
  13. * - $field->value: Value of the profile field.
  14. * - $field->type: Type of the profile field, i.e., checkbox, textfield,
  15. * textarea, selection, list, url or date.
  16. *
  17. * Since $profile is keyed, a direct print of the field is possible. Not
  18. * all accounts may have a value for a profile so do a check first. If a field
  19. * of "last_name" was set for the site, the following can be used.
  20. *
  21. * <?php if (isset($profile['last_name'])): ?>
  22. * <div class="field last-name">
  23. * <?php print $profile['last_name']->title; ?>:<br />
  24. * <?php print $profile['last_name']->value; ?>
  25. * </div>
  26. * <?php endif; ?>
  27. *
  28. * @see template_preprocess_profile_block()
  29. */
  30. ?>
  31. <?php print $user_picture; ?>
  32. <?php foreach ($profile as $field) : ?>
  33. <p>
  34. <?php if ($field->type != 'checkbox') : ?>
  35. <strong><?php print $field->title; ?></strong><br />
  36. <?php endif; ?>
  37. <?php print $field->value; ?>
  38. </p>
  39. <?php endforeach; ?>