Code Monkey home page Code Monkey logo

Comments (11)

markifornia avatar markifornia commented on June 23, 2024 3

@gorkijatt this is a great solution but the main master repository needs to be updated with this somehow - not sure if the author is still actively updating this library.

my solution was using jquery, sort of a temporary bandaid until we can pull the next updated version.


<script>
$(document).ready(function() {

  $('.pagination li').addClass('page-item');
  $('.pagination li a').addClass('page-link');
});
</script>

from php-paginator.

gorkijatt avatar gorkijatt commented on June 23, 2024 2

For Bootstrap 4 You Need to update css classes
go to your vendor path mine look like this vendor/jasongrimes/paginator/src/JasonGrimes/Paginator.php

edit Paginator.php file look for toHtml() function comment the old function or replace the function with code below :)

public function toHtml()
{
    if ($this->numPages <= 1) {
        return '';
    }

    $html = '<ul class="pagination">';
    if ($this->getPrevUrl()) {
        $html .= '<li class="page-item"><a class="page-link" href="' . htmlspecialchars($this->getPrevUrl()) . '">&laquo; '. $this->previousText .'</a></li>';
    }

    foreach ($this->getPages() as $page) {
        if ($page['url']) {
            $html .= '<li' . ($page['isCurrent'] ? ' class="active page-item"' : '') . '><a class="page-link" href="' . htmlspecialchars($page['url']) . '">' . htmlspecialchars($page['num']) . '</a></li>';
        } else {
            $html .= '<li class="disabled page-item"><span class="page-link">' . htmlspecialchars($page['num']) . '</span></li>';
        }
    }

    if ($this->getNextUrl()) {
        $html .= '<li class="page-item"><a class="page-link" href="' . htmlspecialchars($this->getNextUrl()) . '">'. $this->nextText .' &raquo;</a></li>';
    }
    $html .= '</ul>';

    return $html;
}

from php-paginator.

alexSivka avatar alexSivka commented on June 23, 2024 1

Because the maintainer seems has gone away, i cloned this repo and add feature of bootstrap-4. Is here https://github.com/alexSivka/php-paginator . composer require sivka/paginator

from php-paginator.

markifornia avatar markifornia commented on June 23, 2024

We need bootstrap 4 pagination list item classes - should be easy to add.

https://www.w3schools.com/bootstrap4/bootstrap_pagination.asp

from php-paginator.

gorkijatt avatar gorkijatt commented on June 23, 2024

@markifornia that was clean.

from php-paginator.

markifornia avatar markifornia commented on June 23, 2024

@gorkijatt we might need to maintain this library if the author isn't active.

from php-paginator.

gorkijatt avatar gorkijatt commented on June 23, 2024

Okae i m in.

from php-paginator.

cstalvey avatar cstalvey commented on June 23, 2024

Replace the toHtml method with this one for bootstrap 4.1 with the breakpoints for the small template.

public function toHtml(){
    if ($this->numPages <= 1) {
        return '';
    }
    
    $html = '<ul class="pagination justify-content-center d-none d-md-flex">';
    if ($this->getPrevUrl()) {
        $html .= '<li class="page-item"><a class="page-link" href="' . htmlspecialchars($this->getPrevUrl()) . '">&laquo; '. $this->previousText .'</a></li>';
    }
    
    $pages = $this->getPages();
    foreach ($pages as $page) {
        if ($page['url']) {
            $html .= '<li class="page-item' . ($page['isCurrent'] ? ' active' : '') . '"><a class="page-link" href="' . htmlspecialchars($page['url']) . '">' . htmlspecialchars($page['num']) . '</a></li>';
        } else {
            $html .= '<li class="page-item disabled"><span class="page-link">' . htmlspecialchars($page['num']) . '</span></li>';
        }
    }

    if ($this->getNextUrl()) {
        $html .= '<li class="page-item"><a class="page-link" href="' . htmlspecialchars($this->getNextUrl()) . '">'. $this->nextText .' &raquo;</a></li>';
    }
    $html .= '</ul>';
    
    $html .= '<ul class="pagination justify-content-center d-md-none">';
    if ($this->getPrevUrl()) {
        $html .= '<li class="page-item"><a class="page-link" href="' . htmlspecialchars($this->getPrevUrl()) . '">&laquo; '. $this->previousText .'</a></li>';
    }
    
    $html .= '<li class="page-item"><select class="form-control paginator-select-page rounded-0">';
    foreach ($pages as $page) {
        if ($page['url']) {
            $html .= '<option value="' . htmlspecialchars($page['url']) . '"' . ($page['isCurrent'] ? ' selected' : '') . '>' . htmlspecialchars($page['num']) . '</option>';
        } else {
            $html .= '<option disabled>' . htmlspecialchars($page['num']) . '</option>';
        }
    }
    $html .= '</li></select>';
    
    if ($this->getNextUrl()) {
        $html .= '<li class="page-item"><a class="page-link" href="' . htmlspecialchars($this->getNextUrl()) . '">'. $this->nextText .' &raquo;</a></li>';
    }
    $html .= '</ul>';
    
    return $html;
}

from php-paginator.

alanzhaonys avatar alanzhaonys commented on June 23, 2024

Any update?

from php-paginator.

 avatar commented on June 23, 2024

I am trying to implement this class with mysql but no luck so far, can anbody help?

from php-paginator.

ignitedevapps avatar ignitedevapps commented on June 23, 2024

@alexSivka thank you for taking this package in under your wings.

I'll be sure to note any issues/feedback.

Cheers
Mark

from php-paginator.

Related Issues (9)

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.