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

Bootstrap 4 compatibility #17

Open
ArlingtonHouse opened this issue Dec 8, 2017 · 11 comments
Open

Bootstrap 4 compatibility #17

ArlingtonHouse opened this issue Dec 8, 2017 · 11 comments

Comments

@ArlingtonHouse
Copy link

I saw there's a pull request that failed, would like to revisit this. Basically just need a couple new classes. #15 Thanks!

@markifornia
Copy link

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

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

@gorkijatt
Copy link

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;
}

@markifornia
Copy link

@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>

@gorkijatt
Copy link

@markifornia that was clean.

@markifornia
Copy link

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

@gorkijatt
Copy link

Okae i m in.

@cstalvey
Copy link

cstalvey commented Sep 8, 2018

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;
}

@alanzhaonys
Copy link

Any update?

@ghost
Copy link

ghost commented Jan 18, 2020

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

@alexSivka
Copy link

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

@ignitedevapps
Copy link

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

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

Cheers
Mark

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

7 participants