cakephp 3 bootstrap-ui change prev/next text

252 Views Asked by At

I have FriendsofCake Bootstrap-ui plugin. I see in the source that it accepts text for the pagination prev and next labels.

I am not sure how to exactly set the config option though.

PaginatorHelper.php

    if (isset($options['next'])) {
        if ($options['next'] === true) {
            $options['next'] = $this->config('labels.next');
        }
        $options['after'] = $this->next($options['next'], ['escape' => false]) . $options['after'];
    }

I was trying this below in the bootstrap.php but no effect

Configure::write('friendsofcake.PaginatorHelper.labels.prev', 'previous');

But I see they are also set in the __construct

Answer

With the help from drmonkeyninja here is the exact code needed to configure the labels in the AppView.php

$this->loadHelper(
    'Paginator',
    [
        'className' => 'BootstrapUI.Paginator',
        'labels' => [
            'prev' => 'previous',
            'next' => 'next',
        ]
    ]
);
1

There are 1 best solutions below

1
On BEST ANSWER

This appears to be badly documented, but to configure any of the settings for a helper you need to pass them as an array when you load it. So for example, if you are loading the Paginator helper inside your AppView you would pass prevlike this:-

$this->loadHelper(
    'Paginator', 
    [
        'className' => 'BootstrapUI.Paginator', 
        'prev' => 'previous'
    ]
);