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: Customizing comments counter in SOBI2 V-Card
Pages: [1]   Go Down
  Print  
Author Topic: Customizing comments counter in SOBI2 V-Card  (Read 2442 times)
0 Members and 2 Guests are viewing this topic.
Wiz
Newbie
*

Karma: 0
Offline Offline

Posts: 15


« on: December 07, 2010, 08:37:00 »

Hola,

I put this into my v-card and it works fine...
Code:
<?php


  $comments 
JPATH_SITE DS .'components' DS 'com_jcomments' DS 'jcomments.php';
  if (
file_exists($comments)) {
    require_once(
$comments);
    
$count JComments::getCommentsCount($id'com_sobi2');
    echo 
$count ? ('Comments('$count ')') : 'Add comment';
  }


?>

I just wanna ask on how to make it go to comments, when user click at 'Comments (1)' or 'Add comment'.

Thanks  Grin
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #1 on: December 07, 2010, 16:04:10 »

I don't use SOBI2 so I don't know what type of information is displayed on v-card. The code you post shows comments counter for certain item. Do you want to add link to this item?
Logged

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

Karma: 0
Offline Offline

Posts: 15


« Reply #2 on: December 09, 2010, 18:46:25 »

Yes Smart, i want to put a link to commented item...how do i achieve this?  Cheesy

Thanks...
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #3 on: December 09, 2010, 19:01:50 »

You can use following code:

Code: (php)
<?php
  $comments 
JPATH_SITE DS .'components' DS 'com_jcomments' DS 'jcomments.php';
  if (
file_exists($comments)) {
    require_once(
$comments);
    
$count JComments::getCommentsCount($id'com_sobi2');
    
$link JCommentsObjectHelper::getLink($id'com_sobi2');
    echo 
$count ? ('<a href="'.$link.'#comments">Comments('$count ')</a>') : '<a href="'.$link.'#addcomment">Add comment</a>';
  }
?>
Logged

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

Karma: 0
Offline Offline

Posts: 15


« Reply #4 on: December 09, 2010, 19:28:18 »

Works great!  Cheesy Thanks very much... Grin

Just 1 more question...for non-registered user, how do I add 'Please login to comment'.  Grin

Thanks... Cheesy
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #5 on: December 09, 2010, 21:40:38 »

This code do validation user's permissions to comment:

Code: (php)
$acl = & JCommentsFactory::getACL();
if ($acl->canComment()) {
  // user can comment
} else {
  // user can't comment
}

so we could use this function in our code:

Code: (php)
<?php
  $comments 
JPATH_SITE DS .'components' DS 'com_jcomments' DS 'jcomments.php';
  if (
file_exists($comments)) {
    require_once(
$comments);
    
$count JComments::getCommentsCount($id'com_sobi2');
    
$link JCommentsObjectHelper::getLink($id'com_sobi2');
    
$acl = & JCommentsFactory::getACL();
    echo 
$count ? ('<a href="'.$link.'#comments">Comments('$count ')</a>') : ($acl->canComment() ? ('<a href="'.$link.'#addcomment">Add comment</a>') : ('<a href="'.JRoute::_('index.php?option=com_user&task=register').'">Please login to comment</a>'));
  }
?>

It will display 'Comments(10)' if there are 10 comments and 'Add comment' if 0 comments and user has permissions to post new comment or 'Please login to comment' if he hasn't.

Also I can suggest you to setup appropriate messate in JComments settings - it will be displayed to users who has no permissions to post comments. Otherwise they would see nothing if there are no comments for certain item.
« Last Edit: December 09, 2010, 21:47:13 by smart » Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Integration with third-party extensions    Topic: Customizing comments counter in SOBI2 V-Card
 
Jump to: