fonctionnalité like and dislike of a post
This commit is contained in:
@@ -12,10 +12,25 @@
|
||||
<p class="card-text">{{ post.commentary }}</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
{{ post.likes.count() }} ❤️
|
||||
<span class="likes-count">{{ post.likes.count() }}</span>
|
||||
{% if app.user %}
|
||||
<button class="like-toggle btn no-style {% if post.likes.contains(app.user) %}liked{% else %}not-liked{% endif %}"
|
||||
data-post-id="{{ post.id }}"
|
||||
data-like-url="{{ path('app_posts_like', {id: post.id}) }}"
|
||||
data-unlike-url="{{ path('app_posts_unlike', {id: post.id}) }}">
|
||||
{% if post.likes.contains(app.user) %}❤️{% else %}♡{% endif %}
|
||||
</button>
|
||||
{% else %}
|
||||
<span class="like-toggle no-style not-liked">♡</span>
|
||||
{% endif %}
|
||||
{{ post.comments.count() }} 💬
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% include '_pagination.html.twig' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
{{ parent() }}
|
||||
<script src="{{ asset('js/like_toggle.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user