You could achieve it with both CSS and preprocess by doing something like this:
In your template.php file, mytheme_preprocess_node():
// START
$node = $vars['node'];
if (!empty($node->links['comment_comments'])) {
// Class depending on node comment count.
if (!empty($node->comment_count)) {
$myclass = 'has-comments';
}
else {
$myclass = 'no-comments';
}
// Add to particular link class.
if (empty($node->links['comment_comments']['attributes']['class'])) {
$node->links['comment_comments']['attributes']['class'] = $myclass;
}
else {
$node->links['comment_comments']['attributes']['class'] .= ' ' . $myclass;
}
// Reformat all links
$vars['links'] = !empty($node->links) ? theme('links', $node->links, array('class' => 'links inline')) : '';
}
// END
In your theme's css file
/* START */
.has-comments {
backgorund-image: url(./images/some-image.png);
background-repeat: none;
padding-left: 2em;
}
.no-comments {
background-image: none;
padding-left: 0;
}
/* END */
On Thu, 18 Nov 2010 12:31:23 -0700Yes i misunderstood it, i thought it was some kind of overriding
Carl Wiedemann <carl.wiedemann@gmail.com> wrote:
> $vars['links'] is generated by theme_links(). Look at
> template_preprocess_node() in includes/theme.inc:
> http://drupalcode.org/viewvc/drupal/drupal/includes/theme.inc?revision=1.415.2.27&view=markup&pathrev=DRUPAL-6-18-SECURITY#l1955
>
> $variables['links'] = !empty($node->links) ? theme('links',
> $node->links, array('class' => 'links inline')) : '';
As i said in the previous comment, in some cases, i'd want only the icon which
> Unless you absolutely consider the icons to be content and not styling, CSS
> is the way to go instead of <img> tags. Different CSS classes may be applied
> via theme_links() to indicate whether comments exist. CSS also allows for
> the use of sprites.
i suppose i can't achieve only with CSS.