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

Login with username, password and session length

JoomlaTune Support Forum    JComments component    Integration with third-party extensions    Topic: Quantity latest news module
Pages: [1]   Go Down
  Print  
Author Topic: Quantity latest news module  (Read 2121 times)
0 Members and 1 Guest are viewing this topic.
Wil
Newbie
*

Karma: 0
Offline Offline

Posts: 6


« on: March 09, 2010, 03:45:29 »

Hi, I've been trying to get the quantity inserted within the latest news module. No luck so far!
Could someone give a clue, please:

This is the code:
mod_latestnews/helper.php:
Code:
$i = 0;
$lists = array();
$jcommentsFile = JPATH_SITE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php';
if (file_exists($jcommentsFile)) {require_once($jcommentsFile);
//$id = $this->item['object_id'];
$count2 = JComments::getCommentsCount($id, 'com_content');
}
foreach ( $rows as $row )
{
if($row->access <= $aid)
{
$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
} else {
$lists[$i]->link = JRoute::_('index.php?option=com_user&view=login');
}
$lists[$i]->comments = $count2;
$lists[$i]->text = htmlspecialchars( $row->title );
$lists[$i]->created = JHTML::_('date', $row->created, JText::_('%d-%m'));
$title_max = 30;
        if ( strlen($row->title) > $title_max ) {
            $lists[$i]->text2 = substr( htmlspecialchars($row->title), 0, $title_max - 3 ) . '...';
            }
else {
           $lists[$i]->text2 = htmlspecialchars( $row->title );
       }
$i++;
}

return $lists;
}
}

And in the default.php:
Code:
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>

<?php foreach ($list as $item) :  ?>
<img src="/images/M_images/indent1.png" alt="">
    <?php echo $item->created?>
<a href="<?php echo $item->link?>" title='<?php echo $item->text?>' class="<?php echo $params->get('moduleclass_sfx'); ?>">
<?php echo $item->text2?>
</a><?php if (isset($item->comments)) : ?><span><?php echo JText::_('(') . $item->comments .(')'); ?></span><?php endif; ?><br>
<?php endforeach; ?>
<a href="index.php/laatste-nieuws.html" title="More news"><?php echo '<b><img src="/images/M_images/indent1.png" border="0" alt="More news!">&nbsp;More...</b>'?></a>

If someone has a clue, very much appriciated Wink
Logged
smart
Administrator
Hero Member
*****

Karma: 146
Offline Offline

Gender: Male
Posts: 2579



WWW
« Reply #1 on: March 09, 2010, 23:16:47 »

This method also will produce more database queries than needed. I think that more correct way is getting comments count for all displayed in module news through one query and than displayend apropriate counter for news. This could decrease database load...
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
Wil
Newbie
*

Karma: 0
Offline Offline

Posts: 6


« Reply #2 on: March 10, 2010, 03:04:08 »

Okay, thanks for your reply!
Beter way is an extra table when a comment is placed. Same like a.hits! But that will be to much work, rewriting functions and so on!
« Last Edit: March 10, 2010, 17:22:06 by Wil » Logged
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Integration with third-party extensions    Topic: Quantity latest news module
 
Jump to: