How to Override Core Functionality in your Theme
If you wanted to add right double angle quotes or raquo to each of your comment block comments. First you would track down the functionality that needs changing to theme_comment_block() inside the comments module ..
function theme_comment_block() {
$items = array();
$number = variable_get('comment_block_count', 10);
foreach (comment_get_recent($number) as $comment) {
$items[] = l($comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) . ' ' . t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->changed))) . '';
}
if ($items) {
return theme('item_list', array('items' => $items));
}
else {
return t('No comments available.');
}
}
function comment_block_view($delta = '') {
if (user_access('access comments')) {
$block['subject'] = t('Recent comments');
$block['content'] = theme('comment_block');
return $block;
}
}
and then make your changes by overriding theme_comment_block inside your theme's template.php as ..
function mytheme_comment_block() {
$items = array();
$number = variable_get('comment_block_count', 10);
foreach (comment_get_recent($number) as $comment) {
$items[] = l('» ' . $comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid, 'html' => true)) . ' ' . t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->changed))) . '';
}
if ($items) {
return theme('item_list', array('items' => $items));
}
else {
return t('No comments available.');
}
}
After clearing the cache your theme function will be now called instead of the theme function provided by the core comment module.
Tags: