templates/games/list.html.twig line 1
{% extends 'base.html.twig' %}
{% trans_default_domain "gamepage" %}
{% block title %}{{ ("category-" ~ category.slug)|trans({},"categories",app.request.getLocale()) }} | {% trans %}SpeakyPlanet{% endtrans %}{% endblock %}
{% block pageTitle %}{{ ("category-" ~ category.slug)|trans({},"categories",app.request.getLocale()) }}{% endblock %}
{% block body %}
<script>
var currentPage = 1;
var maxPage = {{ nbPages }};
$(document).ready(function() {
$( ".pagination li" ).click(function() {
console.log(currentPage);
console.log(maxPage);
if($(this).hasClass('previous')){
console.log('previous');
if(currentPage > 1)
currentPage--;
}else if($(this).hasClass('next')){
console.log('next');
if(currentPage < maxPage)
currentPage++;
}else{
console.log($( ".pagination li" ).index( this ));
currentPage = $( ".pagination li" ).index( this );
}
$( ".pagination li" ).removeClass('active');
$( ".pagination li:nth-child("+ (currentPage+1) +")" ).addClass('active');
$( ".gamePage" ).hide();
$( "#page"+currentPage ).show();
return false;
});
});
</script>
<style>
.card-text {
font-size: 10px;
font-weight: bold;
text-transform: uppercase;
color: #0071BC;
width: 265px;
margin: 0;
}
a:hover .card-text {
color: #f26528;
}
.card-body .theme {
font-size: 15px;
color: #0071BC;
width: 265px;
font-style: italic;
}
.bot-right {
bottom: 0;
right: 0;
}
</style>
{% set page = 1 %}
{% set lock = user is null or not user.isSubscribed %}
<div class="gamePage row row-cols-1 row-cols-sm-2 row-cols-md-3 g-4" id="page{{ page }}">
{% for game in games %}
{% if loop.index0 > 0 and loop.index0%nbPerPage == 0 %}
{% set page = page+1 %}
<div class="clearfix" ></div>
</div>
<div class="gamePage row row-cols-1 row-cols-sm-2 row-cols-md-3 g-4" id="page{{ page }}" style="display: none;">
{% endif %}
{% set zoneId = 'game' ~ game.uniqueId %}
<a class="text-decoration-none text-muted" role="button" href="{{ path('play_game', { 'slug': game.canonicalTitle }) }}">
<div class="col px-4 position-relative">
<div class="card shadow-sm">
<div class="text-center">
<img class="card-img-top mx-auto d-block" alt="{{ game.canonicalTitle }}" src="{% if game.thumbnail is not null %}{{ asset(game.thumbnailUrl) }}{% endif %}" />
</div>
<div class="card-body py-1">
<p class="card-text">{{ 'gtitle'|trans({},zoneId,app.request.getLocale()) }}</p>
<p class="theme text-left py-0 my-0">{% if isTheme is defined and isTheme == 1 %}{% if game.mainCategory %}{{ ("category-" ~ game.mainCategory.slug)|trans({},'categories',app.request.getLocale()) }}{% endif %}{% else %}{% if game.mainTheme %}{{ ("category-" ~ game.mainTheme.slug)|trans({},'categories',app.request.getLocale()) }}{% endif %}{% endif %}</p>
{#<div class="vote {{ 'r' ~ game.roundMark }}"> </div>#}
</div>
{% if lock and not game.free %}
<img class="position-absolute p-1 bot-right" src="{{ asset('images/default/locker.png') }}" alt="">
{% endif %}
</div>
</div>
</a>
{% else %}
<h3>Il n'y a actuellement aucun jeu dans cette catégorie.</h3>
{% endfor %}
</div>
{% if nbPages >= 1 %}
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center py-4">
<li class="page-item previous">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
{% for i in 1..nbPages %}
<li class="page-item {% if loop.index0 == 0 %}active{% endif %}"><a class="page-link" href="#">{{ i }}</a></li>
{% endfor %}
<li class="page-item next">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
{% endif %}
{% endblock %}