Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created November 22, 2010 16:19
Show Gist options
  • Select an option

  • Save mrchrisadams/710193 to your computer and use it in GitHub Desktop.

Select an option

Save mrchrisadams/710193 to your computer and use it in GitHub Desktop.
<?php
/**
* Implementation of hook_theme().
*/
function custom_theme() {
return array(
'find_a_profile_form' => array(
'arguments' => array('roles' => array(), 'subjects' => array(), 'regions' => array()),
'template' => 'find-a-profile-form',
),
'theme_username' => array(
'arguments' => 'object'
)
)
);
}
function custom_theme_username($object) {
if ($object->uid && $object->name) {
// Shorten the name when it is too long or it will break many tables.
if (drupal_strlen($object->name) > 20) {
$name = drupal_substr($object->name, 0, 15) . '...';
}
else {
$name = $object->name;
}
if (user_access('access user profiles')) {
$output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.'))));
}
else {
$output = check_plain($name);
}
}
else if ($object->name) {
// Sometimes modules display content composed by people who are
// not registered members of the site (e.g. mailing list or news
// aggregator modules). This clause enables modules to display
// the true author of the content.
if (!empty($object->homepage)) {
$output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
}
else {
$output = check_plain($object->name);
}
$output .= ' (' . t('not verified') . ')';
}
else {
$output = check_plain(variable_get('anonymous', t('Anonymous')));
}
return $output;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment