×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Comment count

Comment count 15 years 6 months ago #3829

  • Paulius
  • Paulius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Hello everybody,
Maybe you know witch function is responsible for comment counting?
Thanks

Comment count 15 years 6 months ago #3830

  • Paulius
  • Paulius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
I found soliution but I cant get value of $this->_content_id in module. any sugestions? I need to get content ID

Comment count 15 years 6 months ago #3831

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
insertCountButton() in comment.class.php

Comment count 15 years 6 months ago #3832

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
   function mod_commentsGetMostCommented(&$params)
    {
 
	$comObject = &$this->_comObject;
 
	$rows = $comObject->mod_commentsGetMostCommentedQuery($this->_secids, $this->_catids, $this->_maxlines);
		/*
		 * rows must contains row array with following fields :
		 * - $row['id']
		 * - $row['title']
		 * - $row['countid']
		 */
//	global $database;
	//echo $database->getQuery();
 
	    /*
	     * display
	     */
	$html = '';
 
	$maxlinesize = intval($params->get('linesize', 0));
 
	if (!$rows) {
	    $html = "<SPAN class=\"small\"><i>no comments</i></SPAN>";
	} else {
	    $html .= "\n<ul class=\"mod_comments\">\n";
	    foreach($rows as $row) {
//		var_dump($row);
		$id 		= $row['id'];
		$title 		= $row['title'];
		$countid 	= $row['countid'];
 
		$link = $comObject->linkToContent($id);
		$end 	= " (". $countid .")";
		$line	= $maxlinesize ? JOSC_utils::setMaxLength($title, $maxlinesize-JString::strlen($end)): $title;
		$html .= "\n<li class=\"mod_comments\">\n";
		$html .= "\n <a href=\"$link\">". $line ."</a>\n";
		$html .= "$end";
		$html .= "\n</li>\n";
 
	    }
	    $html .= "\n</ul>\n";
	}
	return $html;
    }
 

$id is the id of the content page

Comment count 15 years 6 months ago #3835

  • Paulius
  • Paulius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Actualy I want to put comment number in globalnews link so it will be news bla bla bla (number of comments)
is it posible to do?

Comment count 15 years 6 months ago #3836

  • Paulius
  • Paulius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
 
<?php
 
defined('_JEXEC') or die('Restricted access'); ?>
 
 
 
<div class="gn_list_<?php echo $globalnews_id; ?>">
  <ul>
    <?php foreach ($list as $item) :  ?>
    <li> <?php
 
$database =& JFactory::getDBO();
global $database;
 
 
$com = $this->_component;
$query = "SELECT COUNT(*) FROM jos_comment WHERE contentid='2043'";
       $database->SetQuery($query);
       $number = $database->loadResult();
 
 
	 echo $item->title."(".$number.")"; 
 
	?> </li>
    <?php endforeach; ?>
    <?php if ( $more == 1 && $group->link ) { ?>
   <br> <div class="gn_more"> <?php echo JHTML::_('link', $group->link, JText::_('More news...') ); ?> 
    <?php } ?>
  </ul>
</div>
 
 

$query = "SELECT COUNT(*) FROM jos_comment WHERE contentid='2043'"; here if I write exactly number then I get what I need

but I need to get content ID which is id of news article

Comment count 15 years 6 months ago #3837

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
look at this function
$link = $comObject->linkToContent($id);

$comObject is the content plugin.

The linkToContent funciton creates the link. So open the plugin, look at the code and add you select COUNT to this function and generate the link you want.

Comment count 15 years 6 months ago #3838

  • Paulius
  • Paulius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
so how I can get item id for the code what I post?

Comment count 15 years 6 months ago #3841

  • Paulius
  • Paulius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
function mod_commentsGetMostCommented(&$params)
    {
 
$comObject = &$this->_comObject;
 
$rows = $comObject->mod_commentsGetMostCommentedQuery($this->_secids, $this->_catids, $this->_maxlines);
/*
 * rows must contains row array with following fields :
 * - $row['id']
 * - $row['title']
 * - $row['countid']
 */
// global $database;
//echo $database->getQuery();
 
    /*
     * display
     */
$html = '';
 
$maxlinesize = intval($params->get('linesize', 0));
 
if (!$rows) {
    $html = "<SPAN class=\"small\"><i>no comments</i></SPAN>";
} else {
    $html .= "\n<ul class=\"mod_comments\">\n";
    foreach($rows as $row) {
// var_dump($row);
$id  = $row['id'];
$title  = $row['title'];
$countid  = $row['countid'];
 
$link = $comObject->linkToContent($id);
$end  = " (". $countid .")";
$line = $maxlinesize ? JOSC_utils::setMaxLength($title, $maxlinesize-JString::strlen($end)): $title;
$html .= "\n<li class=\"mod_comments\">\n";
$html .= "\n <a href=\"$link\">". $line ."</a>\n";
$html .= "$end";
$html .= "\n</li>\n";
 
    }
    $html .= "\n</ul>\n";
}
return $html;
    }

How can I call function mod_commentsGetMostCommented(&$params) in another module mod_globalnews that I get content id?
  • Page:
  • 1
Time to create page: 0.179 seconds