-
-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Twig pagination (proposal) and Page Tree (question) #443
Comments
I've tried to work on a better way to integrate this pagination on different template files and I produced this how-to on my website: http://momh.fr/tutos/Pico/pico_twig_pagination @PhrozenByte You can copy this, if you think it's good and useful, into the picocms website. Here it is: inside your
You have to create a
It's awful, but it works ! ^^ A live example: momh.fr/ |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! 👍 |
Comment for un-stale-ing this issue Didn't forget about answering this, just haven't had time for it yet... |
No worry @PhrozenByte :-) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! 👍 |
Comment for un-stale-ing this issue I'm going to work on adding options to display only X items when the maxpage is too important. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! 👍 |
Just in time ! So I've worked on a a way to reduce the number of displayed pages ! Here is my new {% set pagi_next_page = pagi_basepage + 1 %}
{% set pagi_prev_page = pagi_basepage - 1 %}
{% if pagi_max_near_by is null %}
{% set pagi_max_near_by = 2 %}
{% endif %}
{% if pagi_maxpage > 1 %}
<ul>
{% if pagi_prev_page is not null %}
<li class="pi" {% if pagi_prev_page < 1 %}style="visibility: hidden;"{% endif %}><a href="{% if pagi_prev_page == 1 %}{{ pagi_base_url }}{% else %}{{ pagi_base_url ~ '/?' ~ pagi_http_param ~ '=' ~ pagi_prev_page }}{% endif %}" title="Newest posts" id="prev_page_link">Newest posts</a></li>
{% endif %}
{% if pagi_basepage - pagi_max_near_by > 1 %}
<li class="pi">…</li>
{% endif %}
{% for item in range(1, pagi_maxpage|number_format) %}
<li {% if pagi_basepage - pagi_max_near_by > item or pagi_basepage + pagi_max_near_by < item %}style="display:none;"{% endif %} class="pi {%if item == pagi_basepage %} pi_a{%endif %}"><a href="{% if item == 1 %}{{ pagi_base_url }}{% else %}{{ pagi_base_url ~ '/?' ~ pagi_http_param ~ '=' ~ item }}{% endif %}" class="page_item {%if item == pagi_basepage %} page_active{%endif %}">{{ item }}</a></li>
{% endfor %}
{% if pagi_basepage + pagi_max_near_by < pagi_maxpage %}
<li class="pi">…</li>
{% endif %}
{% if pagi_next_page is not null %}
<li class="pi" {% if pagi_next_page > pagi_maxpage %}style="visibility: hidden;"{% endif %}><a href="{{ pagi_base_url ~ '/?' ~ pagi_http_param ~ '=' ~ pagi_next_page }}" title="Older posts" id="next_page_link">Older posts</a></li>
{% endif %}
</ul>
{% endif %} I've made a new blog post about that here: http://momh.fr/tutos/Pico/pico_twig_pagination_bis And you can see it live here: http://momh.fr/?page=5 |
We already promote plugins and themes on our website, unfortunately there isn't really a counterpart for Twig snippets yet. Anyway, creating one might be a good idea. There's just the currently not really used Cookbook on our website. As always, help is highly appreciated! The snippets look really great and are exactly the way it should be used. Just some minor notes:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! 👍 |
HI,
I've worked on a pagination system using Twig and Twig only (after reading #404 and #419), that could be used in any pages of my website. I've managed to reproduce the one I generated with my version on Pico-Pagination for my online website, momh.fr.
So here is the code:
I'm quite satisfied (because it's working ^^ and because I can apply this code, with minor changes, to my tag pages, generated with the PicoTags plugin) but unsatisfied due to the double array parsing (the first one to remove some pages - categories - and the second to display the results).
Maybe you can think of a better way of achieving this ?
I've thought of the new Page Tree system. First, I can't figure out how to use it, even with minimal examples I found in #412 or #414. Even, after reading https://phrozenbyte.github.io/Pico/in-depth/features/page-tree/
Here is a screenshot of my website content folder.
In the
index.twig
, called only for the content rootindex.md
, I've tried several snippets without success... :-/I think I understand that Page Tree could generate from scratch an array without the simple
index.md
nodes ? So, the length of this array wouldn't have to be modified...Is that correct ? If so, could you give me first steps ?
Thanks again and in advance :)
The text was updated successfully, but these errors were encountered: