Difference between revisions of "JPagination/ construct"
From Joomla! Documentation
< API15:JPagination
(New page: ===Description===
Constructor
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
...) |
m (removing red link to edit, no existant pages) |
||
Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Syntax=== | ===Syntax=== | ||
Line 82: | Line 82: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Examples=== | ===Examples=== | ||
Line 97: | Line 97: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API15]] |
Revision as of 13:39, 12 May 2013
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Constructor
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
__construct($total, $limitstart, $limit)
Parameter Name | Default Value | Description |
---|---|---|
$total | The total number of items | |
$limitstart | The offset of the item to start at | |
$limit | The number of items to display per page |
Defined in[edit]
libraries/joomla/html/pagination.php
Importing[edit]
jimport( 'joomla.html.pagination' );
Source Body[edit]
function __construct($total, $limitstart, $limit)
{
// Value/Type checking
$this->total = (int) $total;
$this->limitstart = (int) max($limitstart, 0);
$this->limit = (int) max($limit, 0);
if ($this->limit > $this->total) {
$this->limitstart = 0;
}
if (!$this->limit)
{
$this->limit = $total;
$this->limitstart = 0;
}
if ($this->limitstart > $this->total) {
$this->limitstart -= $this->limitstart % $this->limit;
}
// Set the total pages and current page values
if($this->limit > 0)
{
$this->set( 'pages.total', ceil($this->total / $this->limit));
$this->set( 'pages.current', ceil(($this->limitstart + 1) / $this->limit));
}
// Set the pagination iteration loop values
$displayedPages = 10;
$this->set( 'pages.start', (floor(($this->get('pages.current') -1) / $displayedPages)) * $displayedPages +1);
if ($this->get('pages.start') + $displayedPages -1 < $this->get('pages.total')) {
$this->set( 'pages.stop', $this->get('pages.start') + $displayedPages -1);
} else {
$this->set( 'pages.stop', $this->get('pages.total'));
}
// If we are viewing all records set the view all flag to true
if ($this->limit == $total) {
$this->_viewall = true;
}
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />