Hi everyone! im now to jcomments, i have to say that far as i know and see is the best!!
i found in a topic how to insert the comments count in the front page of a default template,
1. Open file /templates/ja_purity/html/com_content/frontpage/default_item.php
2. Find code:
Code: (php)
<a href="<?php echo $this->item->readmore_link; ?>" class="contentpagetitle<?php echo $this->escape($this->item->params->get( 'pageclass_sfx' )); ?>">
<?php echo $this->escape($this->item->title); ?>
</a>
<?php else : ?>
<?php echo $this->escape($this->item->title); ?>
<?php endif; ?>
and replace with:
Code: (php)
<?php
$commentsCount = 0;
$commentsBlock = '';
$commentsAPI = JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php';
if (is_file($commentsAPI)) {
require_once($commentsAPI);
$config = & JCommentsFactory::getConfig();
$categoryEnabled = JCommentsContentPluginHelper::checkCategory($this->item->catid);
if ($categoryEnabled) {
$commentsCount = JComments::getCommentsCount($this->item->id, 'com_content');
if ($commentsCount) {
$commentsBlock = '<span class="comments-counter"><a href="'.$this->item->readmore_link.'#comments">'.$commentsCount."</a></span>";
} else {
$commentsBlock = '<span class="comments-counter"><a href="'.$this->item->readmore_link.#addcomment">0</a></span>";
}
}
}
?>
<a href="<?php echo $this->item->readmore_link; ?>" class="contentpagetitle<?php echo $this->escape($this->item->params->get( 'pageclass_sfx' )); ?>">
<?php echo $this->escape($this->item->title); ?>
</a>
<?php else : ?>
<?php echo $this->escape($this->item->title); ?>
<?php endif; ?>
<?php echo $commentsBlock; ?>
In this case you'll have block with comments count after article title will be able to style it as you needed. Same modification you'll be needed to make with section and category blog templates.
but the thing is that when i try to use that code in my jateline template frontpage my website just dont show up at all! hehehe
i let you my code of frontpage layout:
<?php
//get Itemid of category
/*
if ($catorsec) {
$catlink = JRoute::_(ContentHelperRoute::getCategoryRoute($rows[0]->catslug, $rows[0]->sectionid));
}else{
$catlink = JRoute::_(ContentHelperRoute::getSectionRoute($rows[0]->sectionid));
$cattitle = ($catorsec) ? $rows[0]->cattitle:$rows[0]->sectitle;
$catdesc = ($catorsec) ? $rows[0]->catdesc:$rows[0]->secdesc;
}*/
$rows = $cat->contents;
$cid = $cat->category->id;
$slug = $cat->category->slug;
$ctitle = $cat->category->title;
$cdesc = $cat->category->description;
$clink = JRoute::_(ContentHelperRoute::getCategoryRoute($slug, $sid));
$cls_sufix = trim($params->get('blog_theme',''));
if($cls_sufix) $cls_sufix = '-'.$cls_sufix;
?>
<div class="ja-box column ja-zintheme<?php echo $cls_sufix;?>">
<div class="inner clearfix">
<?php if ($showcattitle) : ?>
<div class="ja-zincat clearfix">
<h3>
<a href="<?php echo $clink;?>" title="<?php echo trim(strip_tags($cdesc));?>">
<span><?php echo $ctitle;?></span>
</a>
</h3>
</div>
<?php endif; ?>
<?php
$i = 0;
while($i < $s_introitems && $i<count($rows)) {
$row = $rows[$i];
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
$image = $helper->replaceImage ($row, $img_align, $autoresize, $maxchars, $s_showimage, $img_w, $img_h, $hiddenClasses);
//Show the latest news
?>
<div class="ja-zincontent clearfix">
<?php if ($s_showimage && $image) : ?>
<div class="ja-zinimg" style="width:<?php echo $img_w;?>px;height:<?php echo $img_h;?>px;">
<?php echo $image; ?>
</div>
<?php endif; ?>
<h4 class="ja-zintitle"><a href="<?php echo $link;?>" title="<?php echo strip_tags($row->title);?>"><?php echo $row->title;?></a></h4>
<?php if ($showcreater||$showdate) : ?>
<div class="ja-zinmeta clearfix">
<?php if ($showdate) : ?>
<span class="createdate"><?php echo JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC4'));?> <?php if ($showcreater) : ?> | <?php endif; ?> </span>
<?php endif; ?>
<?php if ($showcreater) : ?>
<span class="createby"><?php echo $row->creater;?></span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
if($maxchars > strlen($row->introtext1)) {
echo $row->introtext;
} else {
echo $row->introtext1;
}
?>
<?php if ($showreadmore) : ?>
<a href="<?php echo $link; ?>" class="readon" title="<?php echo JText::sprintf('Read more...');?>"><span><?php echo JText::sprintf('Read more...');?></span></a>
<?php endif; ?>
</div>
<?php
$i++;
}
if (count ($rows) > $i) {
echo "<div class=\"ja-zinlinks\">\n";
echo "<strong>".JTEXT::_('Mas noticias:')."</strong>\n";
echo "<ul>\n";
while (count ($rows) > $i) {
$row = $rows[$i];
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid.""));
?>
<li>
<a title="<?php echo trim(strip_tags($row->title), '"'); ?>" href="<?php echo $link; ?>">
<?php echo $row->title; ?></a>
</li>
<?php
$i++;
}
echo "</ul></div>\n";
}
?>
</div>
</div>
i dont know how to put the php code to show up the comments count there, every where i tried it just screw the site :S
i hope you can helpe me!
regards
carlos!