Hi, I have added 'Recent Comments' (on the blocks page) to my blog, but it just shows the first few words of each comment, but I would prefer to have the commenters name and the title of the specific post show instead. Does anybody have any suggestions?

I have seen the example below on many blogs that show recent posts:

John Smith on xxxxxxxx(blog post title)

I would like to do the same.

Thanks

Comments

PierreEG’s picture

Hello,
with the Display suite module you can easily configure how you want to display your comments.
In the comment display tab of your content type, you have to choose a layout, and then you can decide to display author and the full text of comment.

tesol’s picture

thanks, I will have a look at that.

PierreEG’s picture

Sorry, i didn't understand that you was talking about a module named "recent comments"
I'm not sure that my answer will help you...

tesol’s picture

Thanks for letting me know.

Actually 'Recent Comments' is not a module, it's a block.

Has anybody else got any ideas?

Je K Ryan’s picture

The best way is to use the Views module to create a block, then you can customise it to your heart's content.

The other advantage of using Views is that you can change the configuration at a later date if you redesign or change your mind.

Hope that helps
JK

tesol’s picture

Thanks, I will have a look at that.

tesol’s picture

I have installed Views, but find it very confusing for a newbe like me.

I want to put name of the commentor and the title of the post in Recent Comments like this:

Joe Smith on ..............(the title of the post).......................

I don't want dates.

Is there any documentation on this, or can someone help?

Je K Ryan’s picture

It will seem hard in the beginning, until you get used to the convensions that views uses.

You need to add the User ID as a Contextual Filter (see top right in views) as this will make the user name available to you as a field. In Fields (see centre left), select Comment Title and Comment Author.

I would highly recommend Johan Falk's video series http://nodeone.se/sv/node/20

Hope that helps
JK

tesol’s picture

Thanks for the video links. I will go there and do some study before attempting what you have suggested.

Je K Ryan’s picture

Sorry, but should be add 'Comment:Comments of the node' in Relationship (under Advanced).
Then you'll be able to select comment author and title in Fields.

Apologies for my brain fail.

tesol’s picture

Hi JK, I have gotten so far and it kind of works but not properly, maybe you can give some ideas.

Under 'Advanced' I have this:

Relationships
Comment: Content
(Content) Comment: Comments of the node

On the left side of the page I have this:

Title
Title: Recent comments

Format
Format: HTML list | Settings
Show: Fields | Settings

Fields
Comment: Author
(Content) Content: Title (ON)

Filter criteria
(Content) Content: Published or admin

Sort criteria
(Comments) Comment: Updated date (desc)

This is showing on the View page:

Changeiscoming
ON: New Zealand books

Terry
ON: New Zealand books

mara
ON: New Zealand books

Terry
ON: New Zealand books

mara
ON: New Zealand books

JK, you will notice I have it looking the way it should with the 'author's name' ON 'content title.' However, the same 'content title' shows with all the authors, and they are not in order as they were posted.

I have set the 'Sort Criteria' to ,'decending'

So I am really not sure what I've done wrong or missed, can you suggest anything I should try?

Thanks

vm’s picture

if you want it to sort on based on when the comment was originally posted and not when the comment was updated, you have to remove comment: updated date and set comment: post date

as far as showing the same content for all authors: have those authors commented on the node? and some more than once?

tesol’s picture

VM

"as far as showing the same content for all authors: have those authors commented on the node? and some more than once?"

Yes, they have.

vm’s picture

then that's why they show and show more than once. ultimately that levels out (somewhat) when there is more commenting across multiple nodes on the site. Many comments on a single node tends to mean that node is a 'hot' topic.

tesol’s picture

VM, what does that mean; does it mean I can't do this with views. Most blogs have numerous comments on the same topic, so I don't know. It wouldn't have something to do with threaded comments?

vm’s picture

can't do what with views? you asked for a list of recent comments. The view is giving you a list of recent comments. each of those comments is recent albeit from some of the same authors.

I'm not sure what you are asking.

tesol’s picture

Many, if not most blogs, have recent comments showing sequentually in decending order, so the most recent is at the top. They usually have:

'Author's name' ON 'title of post' (which is what I am aiming for)

I have installed Views specifically to do this, but I am finding out now it doesn't do it properly.

Even the basic default 'recent comments' that comes in drupal lists the recent comments in decending well, except it gives the title of the comment and date (which I don't want).

Has anybody got any ideas on this, or do I just quit Views?

Thanks

vm’s picture

sequential order based on what? if 'comment post date' see my previous comment. based on the previous posting of your settings you included above you are pulling the comment: updated date field and sorting on that field. Which means it's sorting based on the last time the comment was updated and not posted. comments can be edited multiple times which then changes the updated date.

tesol’s picture

VM, I have changed the sort criteria to 'post date' as you suggested.

This is what I should get but don't get (for example):

Bob
ON: Books in New Zealand (5 minutes ago)

Henry
ON: New Zealand Photography (8 minutes ago)

Terry
ON: Books in New Zealand (9 minutes ago)

Bob:
ON: Books in New Zealand (10 minutes ago)

James
ON: Videos about New Zealand (13 minutes ago)

etc etc

I am sure Views can do the above, so I must be doing something wrong. Do you think Views should be able to do this for me?--if it can't I won't waste anymore time on it.

I try everything from using relationships to not using relationships and nothing seems to work properly.
Sometimes I get the same author and the same post title for thirty odd listings.
Sometimes I get a doubling up of the same listing.
Sometimes I get them in the wrong sequentual order.

I have spent hours on this, I have watched the videos on it and tried everything, so I don't know. Is there any other documentation that can clearly tell me how to do this step by step? I am obviously doing something wrong.

Thanks

tesol’s picture

VM, I have decided to delete Views and reinstall it, and this time begin from a cloned 'Recent Comments'

I think I have done something fundamentally wrong, so I am going to start again from scratch.

I will let you know how I get on.

Thanks

tesol’s picture

VM. I Got it!

I was put wrong with the suggestion to add 'Comment:Comments of the node' under 'Avanced.'

Everything is working the way it should.

Thanks

vm’s picture

clone the default recent comments view (it's disabled by default)
adjust the clone as you see fit

PierreEG’s picture

If you don't want to use Views to do this, you can try with this code in your template.php
(replace YOURTHEME by the name of your template)

function YOURTHEME_comment_block() {
  $items = array();
  $number = variable_get('comment_block_count', 10);
  foreach (comment_get_recent($number) as $comment) {
    $items[] = l($comment->name, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) . '&nbsp;<span>' . 'on' . '&nbsp;<span>' . $title = db_query('SELECT title FROM {node} WHERE nid = :nid', array(
      ':nid' => $comment->nid,
        ))->fetchField();
  }

  if ($items) {
    return theme('item_list', array('items' => $items));
  }
  else {
    return t('No comments available.');
  }
}
vm’s picture

rather than throw the above in template.php, I'd suggest making a custom module with it. no need to shove login in the theme for this task.

tesol’s picture

Thanks, guys, for all these suggestions. I will work through them all and see where it goes.

tesol’s picture

How do I make a module?

vm’s picture

you can utilize the block.module example in examples.module

the code will have to be adjusted slightly as it's using a theme function. Personally, I'd just rewrite the entire block function in the custom module. you can obtain the function from the comment.module.

Although I whole heartedly agree that views.module is the easiest way forward as you won't have to deal with creating a module. My suggestion about a module was in reference to using code. You can also export the view (once created) into a custom module.

tesol’s picture

What is the path to the template.php file?
Do I just copy that, change Your Theme to my theme name, and paste it at the bottom of the template.php file? (I don't have to remove anything from the template.php file?

PierreEG’s picture

for the path : /site/all/theme/name of the theme that you're using/template.php
and paste it at the bottom of template.php, you don't have to remove anything in template.php file

function YOURTHEME_comment_block() {
  $items = array();
  $number = variable_get('comment_block_count', 10);
  foreach (comment_get_recent($number) as $comment) {
    $items[] = l($comment->name, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) . '&nbsp;<span>' . 'on' . '</span>&nbsp;<span>' . $title = db_query('SELECT title FROM {node} WHERE nid = :nid', array(
      ':nid' => $comment->nid,
        ))->fetchField();
  }

  if ($items) {
    return theme('item_list', array('items' => $items));
  }
  else {
    return t('No comments available.');
  }
}
tesol’s picture

thanks I will try that