Jump to content

Recommended Posts

So I just want to do comments. I read http://processwire.com/api/fieldtypes/comments/ and this was a good starting point. I want full control of my markup and so <?php echo $page->comments->render();?> is not an option.

So I tried

  <ol id="singlecomments" class="commentlist">
   foreach($page->comments as $comment) {
   if($comment->status < 1) continue; // skip unapproved or spam comments
   $cite = htmlentities($comment->cite); // make sure output is entity encoded
   $text = htmlentities($comment->text);
   $date = date('d.m.Y', $comment->created); // format the date
                            <li class="clearfix">
                                <div class="message">
                                    <div class="info">
                                        <h2><a href=''><?=$cite?></a></h2>
                                        <div class="meta"><?=$date?></div><!-- /.meta -->
                                    </div><!-- /.info -->
                                </div><!-- /.message -->    
                       <?} ?>

And it's working finde. But:

1. I want to add Gravatars, how is the best practice?

2. I want to link $cite to the users website, but how can I achieve this?

3. I want at least paragraphs within $text, in a perfect world ul/ol and links, too.

Link to post
Share on other sites

About Gravatar:

This is also pretty easy to do in PHP, just have a look at their documentation.

No need to request data from their API upfront, you can calculate a hash and assemble the image's src by yourself on the server. This might be something that would be nice to have as a simple module though.

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 gregory
      Hi all, I duplicated the FieldtypeComments module by adding it in site/modules to get the Uikit3 html output.
      Problem: I can't post a comment.
      Where am I doing wrong?
      <?php echo $page->commenti->renderForm(); ?>  

    • By Rhen GWL
      I'm trying to install comments on two of my clients' websites. In both cases, I'm able to display the comment submission form, but the form submissions are not being saved or display. Once I click the submit button, I'm directed to the homepage where #CommentForm is appended to the end of the URL. I have looked through countless forums and Google searches, but I can't find any advice that has fixed this issue. I have followed the instructions from https://processwire.com/docs/modules/guides/comments/ exactly as described, and I'm getting no where.
      Like I said, this is set up on two different websites and I'm seeing the same issues with both. I assume it's some issue with connecting with a database, but I don't see anything in the instructions on PW's website that says I need to do anything there.
    • By eschoonen
      I'm working on the threaded comments on my website and for this I need to include the comments.js
      When I do this it keeps on giving me the "Uncaught ReferenceRrror: jQuery is not defined". Whatever I do it keeps giving me this error message.
      It's the last javascript file that I load in. So how do I fix it?
    • By quickjeff
      Hi Guys,
      I am running a page template that contains a filter form that allows users to display results based on number of  comments. 
      Here is what I am thinking about doing: 
      -add new field called total_comments 
      -somehow populate this field every time a new comment is added or removed by admin with count($page->comments)
      -use form filter to display results that the selector form has found.
      Example: $selector = “total_comments>=$q”; 
      My question to everyone: Is this a good approach? If so how do I get another field to update based on the comment module adding or removing a comment? 
    • 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!  
  • Create New...