I was wondering if it's possible to show activity comments with user picture of the activity comment author. I tried to look at the code however

**
 * Preprocess the comment display to add in the sanitized variables
 */
function template_preprocess_activity_comments_comment(&$vars, $hook) {

// -- > something here for the display of the activity author's pictures
// like ->  $picture = $account->picture;


  $vars['username'] = theme('username', $vars['comment']);
  $vars['comment_value'] = check_plain($vars['comment']->comment);
  $vars['date'] = format_date($vars['comment']->timestamp);
  if (activity_comments_delete_access($vars['comment']->cid)) {
    $vars['delete_link'] = l(t('Delete'), 'activity/comments/delete/' . $vars['comment']->cid, array('query' => drupal_get_destination()));
  }
}

can somebody point me in the right direction in this way please... it will be a great option to have such a feature in this module..

Comments

gausarts’s picture

This is what I did to display the picture along side the comments:

/**
 * Preprocess the comment display to add in the sanitized variables
 *
 */
function mytheme_preprocess_activity_comments_comment(&$vars, $hook) {
  $account = user_load(array('uid' =>$vars['comment']->uid));
  $vars['username'] = theme('username', $vars['comment']);
  
  // Adjust the size to your imagecache preset, you may want to link to profile
  $vars['user_picture'] = theme('imagecache', 'thumb_32x32', $account->picture, strip_tags($vars['username']), strip_tags($vars['username']));
  $vars['comment_value'] = check_plain($vars['comment']->comment);
  $vars['date'] = format_date($vars['comment']->timestamp);
  if (activity_comments_delete_access($vars['comment']->cid)) {
    $vars['delete_link'] = l(t('Delete'), 'activity/comments/delete/' . $vars['comment']->cid, array('query' => drupal_get_destination()));
  }
}

Copy the theme from the module into your theme folder. Adjust the imagecache, variables and also put the new variable "user_picture" inside your activity-comment.tpl.php

I had to redeclare the argument in my theme to get it work last time I did, though. Haven't tried to revert back without hook_theme, but that way it worked.

troyl’s picture

Thanks gausarts

for a quick reply,

I tried to add the function to my theme and override the preprocess as you have pointed,

however it doesn't seem to give out any output.

is there anything I am missing..

this is what I put in my theme..


// Preprocess the comment display to add in the sanitized variables

function MYtheme_preprocess_activity_comments_comment(&$vars, $hook) {
  $account = user_load(array('uid' =>$vars['comment']->uid));
  $vars['username'] = theme('username', $vars['comment']);
  
  // Adjust the size to your imagecache preset, you may want to link to profile
  $vars['user_picture'] = theme('imagecache', 'image_user_default', $account->picture, strip_tags($vars['username']));
  $vars['comment_value'] = check_plain($vars['comment']->comment);
  $vars['date'] = format_date($vars['comment']->timestamp);
  if (activity_comments_delete_access($vars['comment']->cid)) {
    $vars['delete_link'] = l(t('Delete'), 'activity/comments/delete/' . $vars['comment']->cid, array('query' => drupal_get_destination()));
  }
}

and i added this variable to the activity_comment.tpl.php

print $user_picture;

Any help would be great

gausarts’s picture

Perhaps the file name is the problem. No underscore, it's a hyphen: activity-comment.tpl.php

troyl’s picture

Thanks for the quick reply..

I copied the activity-comment.tpl.php to my theme folder and added the variable

print $user_picture;

but to no avail..

is there anything else I am missing

gausarts’s picture

I believe you have cleared the theme registry, so the last step is somehow necessary. You may have to redeclare the template and argument via your hook_theme.

Have you placed something like below into your hook_theme?

    'activity_comments_comment' => array(
      'template' => 'tpl/misc/activity-comment', // adjust the path
      'arguments' => array('comment' => NULL),
    ),

I have never done this with other module overrides, but last time I did was a last resort and worked. I believe this should not be necessary, but

So hopefully the maintainers can tell us in the right direction if any other possible step we missed so we can avoid this.

troyl’s picture

Thanks gausart for your reply,

I finally got the pictures working, but directly altering the activity-comment.tpl.php file,

No matter what I do I can't for the life of it got to accept the template suggestion from my theme.

I think the culprit is this code fragment


    'activity_comments_comment' =>  array(
      'arguments' => array('comment' => NULL),
      'template' => 'activity-comment',
    ),
  );
}

as explained here http://drupal.org/node/223440

it should not be passed as an array

  // Do not do this:
  $variables['template_files'] = array('hook-suggestion');
 
  // Instead do this:
  $variables['template_files'][] = 'hook-suggestion';

but i may be wrong, it would be nice for the maintainers of this module to shed some light on this

I really appreciate your help... thanks

gausarts’s picture

Yes, hopefully we can override it like any other modules.

BTW, that hook_theme is an extra step to avoid "directly altering the activity-comment.tpl.php file", unless you can live with that on the following upgrades :)

Scott Reynolds’s picture

@#6 The module isn't providing a template suggestion(s). You are trying to override a theme hook. See here for in-depth instructions plus examples: http://drupal.org/node/341628

There is no error/bug in Activity code.

troyl’s picture

@#8 I never said module had a bug/error however, what eludes me is that every other module is simply overridden by copying and pasting the *.tpl.php file to the theme and making necessary changes to it, however, this is not the case in the activity_comment module.

I even tried to override the hook_theme() function in my theme template file but to no avail. I checked it with devel but no matter what I do it does not get overridden.

If every module can be overridden by a simple process why would activity_module be different. This leaves a question mark on activity_comment module.

AntiNSA’s picture

subscribe

zuzu83’s picture

an interim solution dans le fichier "activity_comment.tpl.php"

<?php
	$usr = user_load($comment->uid);
	$picture = theme('imagecache', 'your_image_cache_size', ($usr->picture) ? $usr->picture : variable_get('user_picture_default', ''), strip_tags($comment->name));
?>
<div class='container-inline'>
  <span class="activity-user-picture" style="margin-left:-32px;"><?=$picture?></span>
  <span class='activity-user'><?php print $username ?></span>
  <div class='activity-comment'><?php print $comment_value ?></div>
</div>
<div class='activity-comments-meta'>
  <div class='activity-comments-timestamp'>
    <?php print $date; ?>
  </div>
  <?php if (!empty($delete_link)) :?>
    <div class='activity-comments-delete'>
      <?php print $delete_link; ?>
    </div>
  <?php endif; ?>
</div>
_shy’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

D6 reached its EOL back in February 2016, and there is no active release for D6 for this module anymore.
Development or support is not planned for D6. All D6-related issues are marked as outdated in a bunch.

If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.