encho

Comments system - stars and up/down votes

Recommended Posts

Hi all, help needed with comments here. I see that there is a star rating system and possibility to upvote or downvote specific comments. Page on comments still does not go into details, especially about displaying them. I followed other things on that page, including the styling, to the letter. If you include custom code {stars}, stars are displayed but not properly (it shows 5 star only regardless of the rating). Also {votes} does show the arrows but they do not do anything. While in the backend things do work as expected (ie. stars can be set and votes changed). Am I missing something, like custom JavaScript or similar? Anyone else using these features in their comments?

Share this post


Link to post
Share on other sites
1 minute ago, Zeka said:

Hi @encho

I've never used this module, but as far as I see there are comments.js and comments.css which you have to include on your page.

Here is repo of this module https://github.com/processwire/processwire/tree/dev/wire/modules/Fieldtype/FieldtypeComments

Hope it helps.

Thanks, good point. Already used css from their page, but that js might do the trick I hope.

Share this post


Link to post
Share on other sites

Hi encho and Zeka and everybody else who reads my posting. I have the same problem like encho: The comments function works well, but If you include custom code {stars}, stars are displayed but not correctly. It shows 5 star only regardless of the rating.  I am using this code:

<?php echo $page->comments->render(array(
			'headline' => '<h3>Comments</h3>',
			'commentHeader' => 'Posted by {cite} on {created}{stars}{votes}',
			'dateFormat' => 'd.m.Y H:i:s',
			'encoding' => 'UTF-8',
			'admin' => false, // shows unapproved comments if true
		));

In the attached screenshot you can see the result.

Does anyone have any idea how to get the Star Rating function to work correctly?

star-rating-problem.png

Share this post


Link to post
Share on other sites

@Hajosch Looks like something wrong with CSS. Make sure that you load CSS file from comments module and it actually gets loaded and not conflicting with other styles. 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Hello,

I had used comments fieldtype and it works perfect.
Just right now compared what I had used and there are few differences, but first please check did you have on page Comments css and js files:

<link rel="stylesheet" type="text/css" href="<?php echo $config->urls->FieldtypeComments;?>comments.css" />
<script type='text/javascript' src='<?php echo $config->urls->FieldtypeComments;?>comments.min.js'></script>

And call:

<?php echo $page->comments->render(array(
			'headline' => '',
			'commentHeader' => '<span class="comment-by">{cite}
									<span class="date">{created}</span>
									{stars}{votes}
								</span>',
			'useVotes' => 1,
			'useStars' => 1,
			'upvoteFormat' => '<span class="rate-review"><i class="sl sl-icon-like"></i> Helpful Review {cnt}</span>',
			'downvoteFormat' => '<span class="rate-review"><i class="sl sl-icon-dislike"></i> Dislike Review {cnt}</span>'
				));?>

Please check and Comments settings inside admin where you can define stars rating (need to fill form or not).

Regards.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Hello, Zeka,

thank you, that was the right assumption. Being a PHP dilettante, I didn't know how to get the stylesheet for the comments module correctly. I finally tried the following code:

		<!-- Anfang Kommentar- und Page-Rating-Formular -->
		<link rel="stylesheet" href="/wire/modules/Fieldtype/FieldtypeComments/comments.css">
		<?php echo $page->comments->renderAll(); ?>
		<!-- Ende Kommentar- und Page-Rating-Formular -->

And now the star rating function works as it should (see screenshot in the attachment).

Thank you and best greetings to Kiev!

Hajosch

star-rating-loesung.png

Share this post


Link to post
Share on other sites

Hi OLSA,

thanks. Also your solution to call the Comments css and js files is working fine - and the result looks good! I'm becoming more and more a real fan of ProcessWire and its helpful user community.

Hajosch

 

 

 

Share this post


Link to post
Share on other sites

Hi guys, If I use : 

<link rel='stylesheet' type='text/css' href='<?=$config->urls->FieldtypeComments?>comments.css' />
<script type='text/javascript' src="<?= $config->urls->FieldtypeComments?>comments.min.js"></script>
<?php echo $page->comments->renderAll(); ?> 

The comment work, but:

  • I can't see the star system in the form and in the comment, also if I add it in the backend.
  • The up and down vote don't working well, when I add a vote I see the number grow but after reload the page the vote disappear and (correctly) I can't make a new vote.

I try also to customizing the comments output to force the system but this doesn't work.

Some one know what I can try to do?

Thank you.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By quickjeff
      Hey Guys, 
      I am using the https://processwire.com/api/fieldtypes/comments/ to  allow users to comment and rate. Whats the best approach to get an average of all the star ratings for the page?
      Any direction is greatly appreciated!  
    • By mattcohen
      Hi, I am wondering if someone can help me out with getting the count of the comments of a page? 
      I am using Ryan's comments module as a reviews system for my site and would like to display the count of the comments per page, as below 
       

       
      The shops part that you see above is something similar to this 
      <?php $set_page = $page->title; $count = $pages->count("template=prices, title=$set_page"); echo $count; ?>  
    • By mtn
      The "Comments" core module has been activated locally with its four associated parts, including an Akismet API key, and has been rendered as per instruction via http://processwire.com/api/fieldtypes/comments/.  Testing the comment form continues to render errors after this manner in the 3.0.96 version.
      Error: Exception: Invalid email address (processwire@localhost:8888) (in ... /wire/core/WireMail.php line 130)  
      After an exhaustive attempt on my part to overcome this error (with limited knowledge), I considered that maybe a corrupt file might be the cause.  However, after updating from 3.0.62 to 3.0.96, the same error persists.  Below is the particular section/line of code mentioned.
      /** * Sanitize an email address or throw WireException if invalid * * @param string $email * @return string * @throws WireException * */ protected function sanitizeEmail($email) { $email = strtolower(trim($email)); $clean = $this->wire('sanitizer')->email($email); if($email != $clean) { $clean = $this->wire('sanitizer')->entities($email); throw new WireException("Invalid email address ($clean)"); //<--- this is the line } return $clean; }  
      Inasmuch as this is the final element that needs to be addressed for this particular site, your assistance in helping me understand the issue and the remedy regarding this matter would be greatly appreciated.  Good day!
       
    • By gerritvanaaken
      Hi there!
      I need to gather a list of all comments, regardless of the parent page of each comment. Is there a global $comments object, which can do this? Something like:
      foreach($comments->find('sort=-created') as $comment) { // show comment } I did not find anything similar in the forums. Can someone help me?