Last updated March 10, 2010. Created by Kami Petersen on March 10, 2010.
Log in to edit this page.
Description
This illustrates how to change the output of an individual link in the node links area on a theme basis.
Example 1
This shows how to change the comment count string from "5 comments" to simply "5". I like to use this format on top of a background image of a speech bubble.
Add something like this to your theme's template.php file:
<?php
YOUR_THEME_NAME_preprocess_node(&$vars) {
// drupal_set_message('<pre>' . print_r(get_defined_vars(),TRUE) . '</pre>'); // print what variables are available
// drupal_set_message('<pre>' . print_r($vars['node']->links, TRUE . '</pre>')); // print what links are available
// some sanity checks
if ($vars['is_front']) {
if ($vars['node']->comment) {
if (user_access('access comments')) {
// get the comment count
$all = comment_num_all($vars['node']->nid);
if ($all) {
if ($vars['node']->links[comment_comments]['title']) {
$vars['node']->links[comment_comments]['title'] = $all;
}
}
}
}
}
// update the themed links
$vars['links'] = theme_links($vars['node']->links, array('class' => 'links inline'));
}
?>