Giter Club home page Giter Club logo

pagination's Introduction

Pagination


https://nicolai.maliske.net

PHP Anwendung

$pagination = new Pagination();

$pagination->setCurrentPage(5); // (INT) Aktuelle Seite
$pagination->setTotalEntries(600); // (INT) Anzahl aller einträge (z.B. aus einer Datenbank Tabelle)
$pagination->setEntriesPerPage(25); // (INT) Einträge pro Seite, wie viele Einträge angezeigt werden sollen.

$pagination->getLimits(); // (Return Array) Beispiel: ['current' => 1, 'offset' => 0, 'maxPage' => 25];
$result = $pagination->browse();

browse() Ergebnis

Beispiel: http://localhost/test.php?page=5

Array
(
    [prePages] => 3
    [preLinks] => Array
        (
            [2] => 2
            [1] => 3
            [0] => 4
        )

    [nextPages] => 3
    [nextLinks] => Array
        (
            [0] => 6
            [1] => 7
            [2] => 8
        )

    [currentPage] => 5
)

Twig Beispiel für die ausgabe bei "browse()"

<nav aria-label="Page navigation">
    <ul class="pagination">
        {% if totalEntries is defined  %}
            <li class="page-item"><a class="page-link" href="/list/1"><i class='fas fa-angle-double-left'></i>&nbsp;{% trans %}firstPage{% endtrans %}</a></li>
        {% endif %}
        {% for page in pagination.preLinks %}
            <li class="page-item"><a class="page-link" href="/list/{{ page }}">{{ page }}</a></li>
        {% endfor %}
        <li class="page-item active"><a class="page-link" href="/list/{{ pagination.currentPage }}">{{ pagination.currentPage }}</a></li>
        {% for page in pagination.nextLinks %}
            <li class="page-item"><a class="page-link" href="/list/{{ page }}">{{ page }}</a></li>
        {% endfor %}
        {% if totalEntries is defined  %}
        <li class="page-item"><a class="page-link" href="/list/{{ totalEntries }}">{% trans %}lastPage{% endtrans %}&nbsp;<i class='fas fa-angle-double-right'></i></a></li>
        {% endif %}
    </ul>
</nav>

pagination's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.