Theming comments in Omega

Events happening in the community are now at Drupal community events on www.drupal.org.
samwillc's picture

Hi everyone,

Could anyone tell me how to theme the comments sing Omega theme, it may not be theme specific but posting it here as this group seems to be a lot more on the ball than the drupal forum when it comes to activity. I knew it would only be a matter of time that I could sail through this without learning any php code and only learning modules but the time has come to get my hands a little dirtier. So I'm starting basic and seeing where it goes.

I can see in comments.module there is code like this:

/**
* Process variables for comment.tpl.php.
*
* @see comment.tpl.php
*/
function template_preprocess_comment(&$variables) {
  $comment = $variables['elements']['#comment'];
  $node = $variables['elements']['#node'];
  $variables['comment']   = $comment;
  $variables['node']      = $node;
  $variables['author']    = theme('username', array('account' => $comment));
  $variables['created']   = format_date($comment->created);
  $variables['changed']   = format_date($comment->changed);

  $variables['new']       = !empty($comment->new) ? t('new') : '';
  $variables['picture']   = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : '';
  $variables['signature'] = $comment->signature;

  $uri = entity_uri('comment', $comment);
  $uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark'));

  $variables['title']     = l($comment->subject, $uri['path'], $uri['options']);
  $variables['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
  $variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['author'], '!datetime' => $variables['created']));

So I assume the 'submitted by' bit is called in comment.tpl here:

  <div class="submitted">
    <?php print $permalink; ?>
    <?php print $submitted; ?>
  </div>

How would I then go about changing the 'submitted by' to something of my choice, for example so I could just output 'BY USERNAME_HERE'. Does new code have to go in my omega subtheme template.php file? Or do I have to have a new comments.tpl file in my subtheme? Not sure where to start with this other than I have seen other examples use MYTHEME_function_whatever in the template.php file which overrides module functions.

The comments is the only thing right now that doesn't fit with the rest of my site so need to style it out, add a span/div here and there etc. I don't want to edit the core files as obviously they are overwritten during upgrade.

Any suggestions would be very much appreciated. Thanks.

Sam.

Comments

You'll need to add a function

jessebeach's picture

You'll need to add a function to your theme's template.php

function my_theme_name_preprocess_comment(&$variables) {
$variables['submitted'] = t('By !username', array('!username' => $variables['author'],));
}

Hi jessebeach, Thanks for the

samwillc's picture

Hi jessebeach,

Thanks for the info, I'll give it a try. I always try to learn to walk before learning to run! I'm sure this'll throw up a bunch of new ideas in my head, "I wonder if I could do..." :)

Sam.

Omega Framework

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: