templates/forms/comment.html.twig line 1

Open in your IDE?
  1. <div class="comments">
  2.     <hr>
  3.     <h3>Comments</h3>
  4.     
  5.     {% if comments is empty %}
  6.     <div class="border p-3 text-center">
  7.        <i>There are currently no comments here.</i>
  8.     </div>
  9.     {% endif %}
  10.     
  11.     {% for comment in comments %}
  12.         <div class="row comment">
  13.             <div class="col-2 comment-author">
  14.                 {% if comment.user is not empty %}
  15.                     <img src="{{ comment.user.getAvatarURL() }}" width="80px" height="80px" loading='lazy' alt="User Avatar" />
  16.                 {% else %}
  17.                     <img src="https://www.gravatar.com/avatar/e1fe9118ba2d464f85c8c01845cb260b?s=80&r=g&d=mm" width="80px" height="80px" loading='lazy' />
  18.                 {% endif %}
  19.             </div>
  20.             {% apply spaceless %}
  21.             <div class="col-10 comment-content">
  22.                 <strong>
  23.                 {% if comment.authorurl is not empty %}
  24.                     <div><a href="{{comment.authorurl|external_link}}">{{comment.author}}</a></div>
  25.                 {% else %}
  26.                     <div>{{comment.author}}</div>
  27.                 {% endif %}
  28.                 {# if is_granted('IS_AUTHENTICATED_REMEMBERED') and (comment.author == app.user or app.user.isAdmin()) #}
  29.                 {% if is_granted('IS_AUTHENTICATED_REMEMBERED') and app.user.isAdmin() %}
  30.                     <span class="float-right">
  31.                         <a target="_blank" href="/admin/app/comment/{{comment.id}}/edit"><i class="fa fa-pencil"></i> Edit Comment</a>
  32.                     </span>
  33.                 {% endif %}
  34.                 <div>{{ comment.createdat|date("F j, Y") }}</div>
  35.                 </strong>
  36.                 {#<div>{{ comment.commenttext|trim|raw }}</div>#}
  37.                 <div>{{ comment.commenttext|trim }}</div>
  38.             </div>
  39.             {% endapply %}
  40.         </div>
  41.     {% endfor %}
  42.     <br>
  43.     <h3>Leave a Reply</h3>
  44.     {#
  45.     {{ form_start(form) }}
  46.         {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
  47.             Logged in as {{ app.user.getDisplayname() }}.
  48.         {% else %}
  49.             {{ form_row(form.author) }}
  50.             {{ form_row(form.author_email) }}
  51.             {{ form_row(form.author_url) }}
  52.         {% endif %}
  53.         
  54.         {{ form_row(form.comment_text) }}
  55.         
  56.         <input type="submit" class="button" value="Submit Comment" />
  57.         {{ form_row(form._token) }}
  58.     {{ form_end(form, {'render_rest': false}) }}
  59.     #}
  60.     
  61.     {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
  62.     <form method="post" name="comment">
  63.         Logged in as {{ app.user.getDisplayname() }}.
  64.         <div class="form-row">
  65.             <label>Your Comment:</label>
  66.             <textarea class="form-control" name="comment-text" placeholder="The text of your comment..." required></textarea>
  67.         </div>
  68.             <input type="submit" class="button" value="Submit Comment" />
  69.     </form>
  70.     <script>
  71.         $('form[name=comment]').submit(function (e) {
  72.             $.ajax({
  73.                 type: 'post',
  74.                 data: $('form[name=comment]').serialize(),
  75.                 success: function(){
  76.                     location.reload()
  77.                 }
  78.             });
  79.             e.preventDefault()
  80.         })
  81.     </script>
  82.     {% else %}
  83.     <div class="alert alert-warning row">
  84.             Commenting is only accessible to RCS users.
  85.     </div>
  86.     <div style="text-align:center">
  87.         <h3>Have an account? Login to leave a comment!</h3>
  88.         <br>
  89.         <a class="button text-white" href="/sign-in"><i class="fa fa-key"></i> Sign In</a> 
  90.     </div>
  91.     {% endif %}
  92.     
  93. </div>