Home > database >  Bootstrap paginator css not appearing
Bootstrap paginator css not appearing

Time:05-09

I am following this enter image description here.

How i can make the bootstrap css style appear?

Reference code

Paginator code called by the function <?php echo $Paginator->createLinks( $links, 'pagination pagination-sm' ); ?>:

public function createLinks( $links, $list_class ) {
    if ( $this->_limit == 'all' ) {
        return '';
    }


$last       = ceil( $this->_total / $this->_limit );

$start      = ( ( $this->_page - $links ) > 0 ) ? $this->_page - $links : 1;
$end        = ( ( $this->_page   $links ) < $last ) ? $this->_page   $links : $last;

$html       = '<ul >';

$class      = ( $this->_page == 1 ) ? "disabled" : "";
$html       .= '<li ><a href="?limit=' . $this->_limit . '&page=' . ( $this->_page - 1 ) . '">&laquo;</a></li>';

if ( $start > 1 ) {
    $html   .= '<li><a href="?limit=' . $this->_limit . '&page=1">1</a></li>';
    $html   .= '<li ><span>...</span></li>';
}

for ( $i = $start ; $i <= $end; $i   ) {
    $class  = ( $this->_page == $i ) ? "active" : "";
    $html   .= '<li ><a href="?limit=' . $this->_limit . '&page=' . $i . '">' . $i . '</a></li>';
}

if ( $end < $last ) {
    $html   .= '<li ><span>...</span></li>';
    $html   .= '<li><a href="?limit=' . $this->_limit . '&page=' . $last . '">' . $last . '</a></li>';
}

$class      = ( $this->_page == $last ) ? "disabled" : "";
$html       .= '<li ><a href="?limit=' . $this->_limit . '&page=' . ( $this->_page   1 ) . '">&raquo;</a></li>';

$html       .= '</ul>';

return $html;
}
}

CodePudding user response:

This may be due to the generated HTML missing some of the neccessary Bootstrap classes.

Even though you correctly set the pagination class to the <ul> element, I think you are missing classes in <li> and <a> elements.

This is how it should look like based on BS docs:

  <ul >
    <li ><a  href="#">Previous</a></li>
    <li ><a  href="#">1</a></li>
    <li ><a  href="#">2</a></li>
    <li ><a  href="#">3</a></li>
    <li ><a  href="#">Next</a></li>
  </ul>

Try adding .page-item class to <li> element and .page-link class <a> element into your PHP function so it generates correct HTML and you should be fine.

  • Related