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

Login with username, password and session length

JoomlaTune Support Forum    JComments component    General discussion    Topic: How to output "number of comments" elsewhere in Blog Layout
Pages: [1]   Go Down
  Print  
Author Topic: How to output "number of comments" elsewhere in Blog Layout  (Read 2084 times)
0 Members and 1 Guest are viewing this topic.
dbirchmier
Newbie
*

Karma: 0
Offline Offline

Posts: 3


Email
« on: August 31, 2010, 01:05:56 »

Hey Everyone,

First, thanks for the great extension. JComments is awesome!


I'm attempting to make a template change to the position of the NUMBER of comments on the section blog layout page.

Here's my sample page:
http://bridgeview.mpahosting.com/index.php?option=com_content&view=section&layout=blog&id=1&Itemid=2


I've attached an image of what I'm trying to achieve. (I want the NUMBER of comments to be within the article title)



I thought perhaps I could just open up tpl_links.php and use this code:
<?php echo $readmoreLink; ?><?php echo $commentsLink; ?><?php echo $hitsCount; ?>


And add it into my blog_item.php template override. Unfortunately, the echo statements fail to output when in this template file. Presumably because they are dependent upon tpl_links.php.


So how do you suggest I do this? I appreciate your help and advice!


EDIT: I adjusted my title to make it more descriptive of my question, as I foresee some may think I'm asking a CSS / coding question.


* bridgeviewcenter_blogs.jpg (135.02 KB, 1300x1342 - viewed 330 times.)
« Last Edit: September 02, 2010, 01:01:11 by dbirchmier » Logged
dbirchmier
Newbie
*

Karma: 0
Offline Offline

Posts: 3


Email
« Reply #1 on: September 01, 2010, 22:51:54 »

Hey all,

I just wanted to update this thread and explain why I'm posting the question here as opposed to a  CSS/Templating forum:

In order to achieve the desired results I wish in the design, I need to absolutely position the comments output in a nested tag with a relative position.

The problem is that since JComments outputs OUTSIDE of the tag which I need to be the parent container (to achieve the desired position that changes based on the size of the article) I can't position it as I wish.

Ideally, I need the ability to tell it to OUTPUT the number of comments in my section_blog template override.

How can I achieve this, or is there a better way?

Thanks again for your time.
Logged
smart
Administrator
Hero Member
*****

Karma: 146
Offline Offline

Gender: Male
Posts: 2579



WWW
« Reply #2 on: September 02, 2010, 02:31:41 »

For your task you could disable displaying links Comments and Add comment in Content - JComments plugin and add displaying comments count into your blog template manually.

For example, if we're using ja_purity we need do following:

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.
Logged

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

Karma: 0
Offline Offline

Posts: 3


Email
« Reply #3 on: September 02, 2010, 10:20:51 »

Thank you SO MUCH!

That is EXACTLY the information I was looking for.

Using your excellent instruction I was able to achieve precisely the results I desired.

Thank you for teaching me the proper API calls to get the info I need.


Here's the final result if you want to see!

http://bridgeview.mpahosting.com/index.php?option=com_content&view=section&layout=blog&id=1&Itemid=2


Thank you again for taking the time to help out!


I modified the code just a tad, so here's my final in case it can benefit anyone else!

   <?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>";
            }
         }
      }
   ?>
      <?php echo $commentsBlock; ?>


Thanks again!
Logged
hayim
Newbie
*

Karma: 0
Offline Offline

Posts: 1


« Reply #4 on: October 15, 2010, 20:25:33 »


hey guys! thank!!
this helped a lot, thanks again.

I was wondering if you there is a way to add a counter on top of the jcomments in the article layout.

thanks
Logged
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    General discussion    Topic: How to output "number of comments" elsewhere in Blog Layout
 
Jump to: