Skip to content
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

How change style of digg-style pagination? #112

Open
nurzhannogerbek opened this issue Mar 19, 2018 · 0 comments
Open

How change style of digg-style pagination? #112

nurzhannogerbek opened this issue Mar 19, 2018 · 0 comments

Comments

@nurzhannogerbek
Copy link

nurzhannogerbek commented Mar 19, 2018

First of all THANK YOU for this wonderful project!

I use version 3.2.4 to create digg-style pagination. Whats the best way to change style?

I tried this:

{% get_pages %}
<ul class="pagination">
{% if pages.paginated %}
  <li class="page-item">
    <a class="page-link" href="{{ pages.first.path }}" aria-label="First">
      <span aria-hidden="true">&lt;&lt;</span>
      <span class="sr-only">First</span>
    </a>
  </li>
  <li class="page-item">
    <a class="page-link" href="{{ pages.previous.path }}" aria-label="Previous">
      <span aria-hidden="true">&lt;</span>
      <span class="sr-only">Previous</span>
    </a>
  </li>
  {% for page in pages %}
    {% if page == None %}
      <li class="page-item disabled">
        <a class="page-link" href="#" aria-label="...">
          <span aria-hidden="true">...</span>
          <span class="sr-only">...</span>
        </a>
      </li>
    {% else %}
      <li class="page-item {% if page.is_current %} active {% endif %}">
        <a class="page-link" href="{{ page.path }}" aria-label="Page {{page.number}}">
          <span aria-hidden="true">{{ page.label|safe }}</span>
          <span class="sr-only">Page {{page.number}}</span>
        </a>
      </li>
    {% endif %}
  {% endfor %}
  <li class="page-item">
    <a class="page-link" href="{{ pages.next.path }}" aria-label="Next">
      <span aria-hidden="true">&gt;</span>
      <span class="sr-only">Next</span>
    </a>
  </li>
  <li class="page-item">
    <a class="page-link" href="{{ pages.last.path }}" aria-label="Last">
      <span aria-hidden="true">&gt;&gt;</span>
      <span class="sr-only">Last</span>
    </a>
  </li>
{% endif %}
</ul>

The problem of next solution is that {% if page == None %} condition never triggered. Is show all pages. For example in my case from 1 to 200 without any ... symbol.

The second thing which I tried is redefine templates (show_more.html, current_link.html, next_link.html, e.t.c.)
In templates folder of my project I create el_pagination folder with html files like this:

templates
   el_pagination
     - current_link.html
     - next_link.html
     - page_link.html
     - previous_link.html
     - show_pages.html

Then in main template i use:

{% get_pages %}
<ul class="pagination">
   {{ pages.get_rendered }}
</ul>

show_pages.html:

{% for page in pages %}
    {{ page.render_link|default:'<li class="page-item disabled"><span aria-hidden="true">...</span></li>' }}
{% endfor %}

Problem in this solution is that only show_pages.html works (style works). Other templates don't work? How to fix the problem? I want to change style of digg-style pagination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant