Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    JComments component    Suggestions, Wishlists & Feature Requests    Topic: name of user who comment an article
Pages: [1]   Go Down
  Print  
Author Topic: name of user who comment an article  (Read 908 times)
0 Members and 2 Guests are viewing this topic.
Nuzzina
Newbie
*

Karma: 0
Offline Offline

Posts: 3


Email
« on: June 26, 2011, 21:01:30 »

Hi Smiley
I'd like to show in my articles also names of users who comment this article. For example:

ARTICLE'S TITLE
text text text text text text
text text text text text text
text text text text text text

Paul, Mike and Jack commented this article.

Paul Comment: blabla..
Mike comment: blaikdijsd
Jack comment: kljdsajpadjadj

Is possible to create a module that do this?
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #1 on: July 26, 2011, 05:13:01 »

You can use simple piece of code (I've tested it in default_item.php):

Code: (php)
<?php

$db 
JFactory::getDBO();
$db->setQuery("SELECT DISTINCT name FROM #__jcomments WHERE object_group = 'com_content' AND object_id = " $this->item->id);
$names $db->loadResultArray();

$countNames count($names);

if (
$countNames 0) {
$lastName = ($countNames 1) ? array_pop($names) : '';
echo implode(', '$names) . ($lastName != '' ' and ' $lastName '') . ' commented this article.';
}
 
?>

If you want to use this code in some other place you should change $this->item->id with appropriate variable.
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Suggestions, Wishlists & Feature Requests    Topic: name of user who comment an article
 
Jump to: