12345678910111213141516171819202122232425262728293031323334353637 |
- {# This needs 3 variables to be set:
- count - how many results to display altogether
- paging_array - array of result pages
- paging_url_base - the base URL for pagination links
- #}
- {% if config.tagblog.paging.items > 0 and count > config.tagblog.paging.items %}
- {% set p = url_param('p','int',1) %}
- {% set paging_url_base = paging_url_base ~ 'p=' %}
- {% set offset = (p - 1) * config.tagblog.paging.items %}
- {% set lastpage = count//config.tagblog.paging.items %}
- {% if count%config.tagblog.paging.items > 0 %}{% set lastpage = lastpage + 1 %}{% endif %}
- {% if config.tagblog.paging.top %}
- {% block pagination %}
- <div class="pagination clearfix">
- {% if offset >= config.tagblog.paging.items %}
- <div class="previous"><span class="first"><a href="{{paging_url_base}}1"><<First</a></span>{% if p > 2 %}<span><a href="{{paging_url_base}}{{p-1}}"><Previous</a></span>{% endif %}</div>
- {% endif %}
- <div class="current">- {{ p }}/{{ lastpage }} -</div>
- {% if offset + config.tagblog.paging.items < count %}
- <div class="next">{% if p +1 < lastpage %}<span><a href="{{paging_url_base}}{{p+1}}">Next></a></span>{% endif %}<span class="last"><a href="{{paging_url_base}}{{lastpage}}">Last>></a></span></div>
- {% endif %}
- </div>
- {% endblock %}
- {% endif %}
- {% for page in paging_array|slice(offset,config.tagblog.paging.items) %}
- {% include 'includes/postlistitem.twig' %}
- {% endfor %}
- {% if config.tagblog.paging.bottom %}
- {{ block('pagination') }}{# same as above #}
- {% endif %}
- {% else %}
- {# if pagination is disabled - just list all pages #}
- {% for page in paging_array %}
- {% include 'includes/postlistitem.twig' %}
- {% endfor %}
- {% endif %}
|