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: Content Hits with Jcomments
Pages: [1]   Go Down
  Print  
Author Topic: Content Hits with Jcomments  (Read 4110 times)
0 Members and 5 Guests are viewing this topic.
Ginza
Newbie
*

Karma: 0
Offline Offline

Posts: 27


« on: September 01, 2010, 22:40:13 »

I really like Jcomments. I am using it my Joomla 1.0.x website.

Is there a way to also include the number of content hits like other comment system like akocomment, JomComment?

It will be great if you could tell me the hack/code to include it.
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #1 on: September 02, 2010, 15:33:47 »

The JComments doesn't allow to display article's hits count in Joomla 1.0 (because outdated mambot architecture). On Joomla 1.5 the JComments content plugin has additional parameter which allows to display such information. But note, that this feature will increase database load because it uses query to database for each content item.

But you could enable this feature manually by making small modification of the default JComments template:

1. Open file /conponents/com_jcomments/tpl/default/tpl_links.php
2. Find code:
Code: (php)
if ($this->getVar('show_hits', 0) == 1) {
and replace it with follows:
Code: (php)
if (true) {

After this content hits counter would be displayed for all articles where comments are enabled.
Logged

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

Karma: 0
Offline Offline

Posts: 27


« Reply #2 on: September 02, 2010, 20:10:00 »

The hits show up on the frontpage and not on the article content. Anyway one step ahead. Thanks.

« Last Edit: September 02, 2010, 20:14:53 by Ginza » Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #3 on: September 02, 2010, 20:57:01 »

If you need to display content hits counter in full article view you'll need to add some additional code to tpl_index.php (this is root template file used for display comments inside article page)
Logged

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

Karma: 0
Offline Offline

Posts: 27


« Reply #4 on: September 02, 2010, 21:04:40 »

Please tell.  Cheesy
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #5 on: September 02, 2010, 21:10:32 »

I don't know where you want to have this counter (you could move it yourself) but I can explain how to show it before comments list.

1. Open file /components/com_jcomments/tpl/default/tpl_index.php
2. Find code:
Code: (php)
$object_id = $this->getVar('comment-object_id');
$object_group = $this->getVar('comment-object_group');
and place after it following code:
Code: (php)
$dbo = & JCommentsFactory::getDBO();
$dbo->setQuery('SELECT hits FROM #__content WHERE id = ' . intval($object_id));
$cnt = (int) $dbo->loadResult();
echo JText::_('Hits') . ': ' . $cnt;
Logged

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

Karma: 0
Offline Offline

Posts: 27


« Reply #6 on: September 02, 2010, 21:35:14 »

Awesome.  Cheesy

How to make it bold?
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #7 on: September 02, 2010, 21:36:26 »

Use Google to find information about HTML Wink
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #8 on: September 03, 2010, 01:01:40 »

Replace
Code: (php)
echo JText::_('Hits') . ': ' . $cnt;
with
Code: (php)
echo '<b>'.JText::_('Hits') . ': ' . $cnt.'</b>';
Logged

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

Karma: 0
Offline Offline

Posts: 27


« Reply #9 on: September 03, 2010, 01:50:45 »

Oh i didn't know that we need to put a quote on it.

Thanks a lot Smart.. that did it!!
Logged
zut
Newbie
*

Karma: 0
Offline Offline

Posts: 1


« Reply #10 on: October 20, 2010, 13:41:41 »

I don't know where you want to have this counter (you could move it yourself) but I can explain how to show it before comments list.

And how about if i would like to place it right under article content, and above jc ?  Wink
Logged
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Suggestions, Wishlists & Feature Requests    Topic: Content Hits with Jcomments
 
Jump to: