CakePHP Paginator Custom Styling

I use the Paginator component and helper.

My style code block is as follows.

    <!-- Pagination -->
    <div class="pagination">
        <ul class="pages">
            <li class="prev"><a href="#">&lt;</a></li>
            <li><a href="#" class="active">1</a></li>
            <li><a href="#">2</a></li>
            <li><a href="#">3</a></li>
            <li class="next"><a href="#">&gt;</a></li>
        </ul>
    </div>

When I try to create pagination using the following

<!-- Pagination -->
<div class="pagination">
    <ul class="pages">
        <?php if($this->Paginator->hasPrev()) echo $this->Paginator->prev('&lt;', array('tag' => 'li', 'escape' => false)); ?>
        <?php echo $this->Paginator->numbers(array('separator' => false, 'tag' => 'li', 'currentClass' => 'active')); ?>
        <?php if($this->Paginator->hasNext()) echo $this->Paginator->next('&gt;', array('tag' => 'li', 'escape' => false)); ?>
    </ul>
</div>

The Active class is assigned li tag, but my template uses the active class toa-href tag

is there any way i can make the cake pass it on a tag?

+4
source share
1 answer

You will need to expand and override the PaginatorHelper :: number () method .

- paginator, aliasing, $this- > Paginator , .

public $helpers = array(
    'Paginator' => array(
        'className' => 'MyPaginator',
    )
);

, , :

public function numbers($options = array()) {
    $numbers = parent::numbers($options);
    /* see explanation below */
    return $numbers;
}

: DOM regex, , <li class="active"><a></a></li> active <li> . , , , , . paginator .

+1

Source: https://habr.com/ru/post/1523276/


All Articles