Sun, 01/31/2010 - 18:36 — David Wei
Drupal is very powerful, it's so flexible that you can use it to build any kind of website with any kind of feature. Here I will show you how I changed some small HTML outputs by simply customize the template.php file.
1. Change the Default Comment Author and Time Style
The default garland template displays comment author's name and time as "author name- Jan 31, 2010 - 04:19", but I would it shows like "author name said on Sun, 01/31/2010 - 15:42", so I just need to add or replace the function in template.php file under my current template folder, with the following code:
function phptemplate_comment_submitted($comment) {
return t('!username said on !datetime',
array(
'!username' => theme('username', $comment),
'!datetime' => format_date($comment->timestamp)
));
}2. Remove the "not verified" Text from Comment Author Names
By default, all non-members of Drupal sites who leave comments will have a "not verified" tag after comment author's name. This is not friendly. Thanks Chadwick Wood, I find the sulution to remove the "not verified" tag from his post: Drupal: How to Remove the "not verified" Text from Comment Author Names.
To do this, you need to override the theme_username function by adding following function code in your template.php file(you need to change yourthemename to your actual theme name):
function yourthemename_username($object) {
if ($object->uid && $object->name) {
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) {
if (!empty($object->homepage)) {
$output = l($object->name, $object->homepage, array(
'attributes' => array('rel' => 'nofollow')));
}
else {
$output = check_plain($object->name);
}
/**
* HERE I've commented out the next line, which is the line
* that was adding the unwanted text to our author names!
*/
// $output .= ' ('. t('not verified') .')';
}
else {
$output = variable_get('anonymous', t('Anonymous'));
}
return $output;
}3. Open the Commentator's Link in a New Window
Linking to other blogs is good, however let your visitor leave your blog for other blogs is no so good. So what do you think about open the commentator's link in a new window? It is very simple, just replace the code in fucntion yourthemename_username:
$output = l($object->name, $object->homepage, array(
'attributes' => array('rel' => 'nofollow')));
with:
$output = l($object->name, $object->homepage, array(
'attributes' => array(
'target' => '_blank', 'rel' => 'nofollow')));
4. And if You Want Your Blog Become DoFollow...
Aha, I think you just find the way! Yes, just replace above code with this:
$output = l($object->name, $object->homepage, array(
'attributes' => array(
'target' => '_blank', 'rel' => 'external')));
Or simply:
$output = l($object->name, $object->homepage, array(
'attributes' => array('target' => '_blank')));
Trackback URL for this post:
- David Wei's blog
- 484 reads

![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_b.png?x-id=e3e56094-d585-4dce-b6c7-b4241ba60be9)

Comments
get your site a DoFollow link by leaving you comments below:Post new comment