home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (profile-block.tpl.php)

This example Drupal source code file (profile-block.tpl.php) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

as, checkbox, endforeach, endif, field, foreach, php, profile

The profile-block.tpl.php Drupal example source code

// $Id: profile-block.tpl.php,v 1.4 2009/08/06 05:05:59 webchick Exp $

 * @file
 * 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 template_preprocess_profile_block()
<?php print $user_picture; ?>

<?php foreach ($profile as $field) : ?>
    <?php if ($field->type != 'checkbox') : ?>
      <strong><?php print $field->title; ?></strong><br />
    <?php endif; ?>
    <?php print $field->value; ?>
<?php endforeach; ?>

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal profile-block.tpl.php source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.