Pagination Helper class for easy generation of pagination links.
PaginationHelper encloses all methods needed when working with pagination.
Cake\View\Helper\PaginatorHelper uses Cake\View\StringTemplateTrait __construct( Cake\View\View $View , array $config [] )
Constructor. Overridden to merge passed args with URL options.
Cake\View\View $View $config optional [] Cake\View\Helper::__construct() _firstNumber( Cake\View\StringTemplate $ellipsis , array $params , integer $start , array $options )
Generates the first number for the paginator numbers() method.
Cake\View\StringTemplate $ellipsis $params $start $options string_formatNumber( Cake\View\StringTemplate $templater , array $options )
Formats a number for the paginator number output.
Cake\View\StringTemplate $templater $options string_getNumbersStartAndEnd( array $params , array $options )
Calculates the start and end for the pagination numbers.
$params $options array_hasPage( string $model , integer $page )
Does $model have $page in its range?
$model $page boolean_lastNumber( Cake\View\StringTemplate $ellipsis , array $params , integer $end , array $options )
Generates the last number for the paginator numbers() method.
Cake\View\StringTemplate $ellipsis $params $end $options string_modulusNumbers( Cake\View\StringTemplate $templater , array $params , array $options )
Generates the numbers for the paginator numbers() method.
Cake\View\StringTemplate $templater $params $options string_numbers( Cake\View\StringTemplate $templater , array $params , array $options )
Generates the numbers for the paginator numbers() method.
Cake\View\StringTemplate $templater $params $options string_toggledLink( string|boolean $text , boolean $enabled , array $options , array $templates )
Generate an active/inactive link for next/prev methods.
$text $enabled $options $templates stringcounter( string|array $options [] )
Returns a counter string for the paged result set
model The model to use, defaults to PaginatorHelper::defaultModel();format The format string you want to use, defaults to 'pages' Which generates output like '1 of 5' set to 'range' to generate output like '1 - 3 of 13'. Can also be set to a custom string, containing the following placeholders {{page}}, {{pages}}, {{current}}, {{count}}, {{model}}, {{start}}, {{end}} and any custom content you would like.$options optional [] stringcurrent( string|null $model null )
Gets the current page of the recordset for the given model
$model optional null integerdefaultModel( )
Gets the default model of the paged sets
string|nullfirst( string|integer $first '<< first' , array $options [] )
Returns a first or set of numbers for the first pages.
echo $this->Paginator->first('< first');
Creates a single link for the first page. Will output nothing if you are on the first page.
echo $this->Paginator->first(3);
Will create links for the first 3 pages, once you get to the third or greater page. Prior to that nothing will be output.
model The model to use defaults to PaginatorHelper::defaultModel()escape Whether or not to HTML escape the text.url An array of additional URL options to use for link generation.$first optional '<< first' $options optional [] stringgenerateUrl( array $options [] , string|null $model null , boolean $full false )
Merges passed URL options with current pagination state to generate a pagination URL.
$options optional [] $model optional null $full optional false stringhasNext( string|null $model null )
Returns true if the given result set is not at the last page
$model optional null booleanhasPage( string|null $model null , integer $page 1 )
Returns true if the given result set has the page number given by $page
$model optional null $page optional 1 booleanhasPrev( string|null $model null )
Returns true if the given result set is not at the first page
$model optional null booleanimplementedEvents( )
Event listeners.
arrayCake\View\Helper::implementedEvents() last( string|integer $last 'last >>' , array $options [] )
Returns a last or set of numbers for the last pages.
echo $this->Paginator->last('last >');
Creates a single link for the last page. Will output nothing if you are on the last page.
echo $this->Paginator->last(3);
Will create links for the last 3 pages. Once you enter the page range, no output will be created.
model The model to use defaults to PaginatorHelper::defaultModel()escape Whether or not to HTML escape the text.url An array of additional URL options to use for link generation.$last optional 'last >>' $options optional [] stringmeta( array $options [] )
Returns the meta-links for a paginated result set.
echo $this->Paginator->meta();
Echos the links directly, will output nothing if there is neither a previous nor next page.
$this->Paginator->meta(['block' => true]);
Will append the output of the meta function to the named block - if true is passed the "meta" block is used.
model The model to use defaults to PaginatorHelper::defaultModel()block The block name to append the output to, or false/absenst to return as a string$options optional [] string|nullnext( string $title 'Next >>' , array $options [] )
Generates a "next" link for a set of paged records
disabledTitle The text to used when the link is disabled. This defaults to the same text at the active link. Setting to false will cause this method to return ''.escape Whether you want the contents html entity encoded, defaults to truemodel The model to use, defaults to PaginatorHelper::defaultModel()url An array of additional URL options to use for link generation.templates An array of templates, or template file name containing the templates you'd like to use when generating the link for next page. The helper's original templates will be restored once next() is done.$title optional 'Next >>' $options optional [] stringnumbers( array $options [] )
Returns a set of numbers for the paged result set uses a modulus to decide how many numbers to show on each side of the current page (default: 8).
$this->Paginator->numbers(['first' => 2, 'last' => 2]);
Using the first and last options you can create links to the beginning and end of the page set.
before Content to be inserted before the numbers, but after the first links.after Content to be inserted after the numbers, but before the last links.model Model to create numbers for, defaults to PaginatorHelper::defaultModel()modulus How many numbers to include on either side of the current page, defaults to 8. Set to false to disable and to show all numbers.first Whether you want first links generated, set to an integer to define the number of 'first' links to generate. If a string is set a link to the first page will be generated with the value as the title.last Whether you want last links generated, set to an integer to define the number of 'last' links to generate. If a string is set a link to the last page will be generated with the value as the title.templates An array of templates, or template file name containing the templates you'd like to use when generating the numbers. The helper's original templates will be restored once numbers() is done.url An array of additional URL options to use for link generation.The generated number links will include the 'ellipsis' template when the first and last options and the number of pages exceed the modulus. For example if you have 25 pages, and use the first/last options and a modulus of 8, ellipsis content will be inserted after the first and last link sets.
$options optional [] stringoptions( array $options [] )
Sets default options for all pagination links
$options optional [] param( string $key , string|null $model null )
Convenience access to any of the paginator params.
$key $model optional null mixedparams( string|null $model null )
Gets the current paging parameters from the resultset for the given model
$model optional null arrayprev( string $title '<< Previous' , array $options [] )
Generates a "previous" link for a set of paged records
disabledTitle The text to used when the link is disabled. This defaults to the same text at the active link. Setting to false will cause this method to return ''.escape Whether you want the contents html entity encoded, defaults to truemodel The model to use, defaults to PaginatorHelper::defaultModel()url An array of additional URL options to use for link generation.templates An array of templates, or template file name containing the templates you'd like to use when generating the link for previous page. The helper's original templates will be restored once prev() is done.$title optional '<< Previous' $options optional [] stringsort( string $key , string|null $title null , array $options [] )
Generates a sorting link. Sets named parameters for the sort and direction. Handles direction switching automatically.
escape Whether you want the contents html entity encoded, defaults to true.model The model to use, defaults to PaginatorHelper::defaultModel().direction The default direction to use when this link isn't active.lock Lock direction. Will only use the default direction then, defaults to false.$key $title optional null $options optional [] stringsortDir( string|null $model null , array $options [] )
Gets the current direction the recordset is sorted
$model optional null $options optional [] stringsortKey( string|null $model null , array $options [] )
Gets the current key by which the recordset is sorted
$model optional null $options optional [] string|null__call( string $method , array $params )
Provide non fatal errors on missing method calls.
$method $params __debugInfo( )
Returns an array that can be used to describe the internal state of this object.
array__get( string $name )
Lazy loads helpers.
$name Cake\View\Helper|null_confirm( string $message , string $okCode , string $cancelCode '' , array $options [] )
Returns a string to be used as onclick handler for confirm dialogs.
$message $okCode $cancelCode optional '' $options optional [] stringaddClass( array $options [] , string $class null , string $key 'class' )
Adds the given class to the element options
$options optional [] $class optional null $key optional 'class' arrayformatTemplate( string $name , array $data )
Format a template string with $data
$name $data stringtemplater( )
templater
Cake\View\StringTemplatetemplates( string|null|array $templates null )
Get/set templates to use.
$templates optional null mixed_configDelete( string $key )
Delete a single config key
$key Cake\Core\Exception\Exception_configRead( string|null $key )
Read a config variable
$key mixed_configWrite( string|array $key , mixed $value , boolean|string $merge false )
Write a config variable
$key $value $merge optional false Cake\Core\Exception\Exceptionconfig( string|array|null $key null , mixed|null $value null , boolean $merge true )
Reading the whole config:
$this->config();
Reading a specific value:
$this->config('key');
Reading a nested value:
$this->config('some.nested.key');
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key optional null $value optional null $merge optional true mixedCake\Core\Exception\ExceptionconfigShallow( string|array $key , mixed|null $value null )
Merge provided config with existing config. Unlike config() which does a recursive merge for nested keys, this method does a simple merge.
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key $value optional null mixedpublic array
Holds the fields ['field_name' => ['type' => 'string', 'length' => 100]], primaryKey and validates ['field_name']
[]
protected boolean
Whether the config property has already been configured with defaults
false public Cake\View\Helper\HtmlHelper
public Cake\View\Helper\UrlHelper
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.View.Helper.PaginatorHelper.html