Tutorials » Pagination
Support
If you plan on having multiple Ditto calls using pagination on one page or using Reflect in your template make sure you use the &id parameter. Set it to a unique string and then update your placeholders to the format [+id_placeholder+].For example, if you id was foo and your palceholder pagetitle, you should use [+foo_pagetitle+]. Also, If you have PHx installed you will need to call Ditto cached on an uncached page.
- Add the following parameters to your Ditto call:
- &summarize = number of results per page
- &paginate = 1
- &paginateAlwaysShowLinks= 1
-
Add the following below your Ditto call:
<p>Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles | Page <strong>[+currentPage+]</strong> of <strong>[+totalPages+]</strong> </p> <div id="ditto_pages"> [+previous+] [+pages+] [+next+] </div> -
Add the following to your CSS file and modify to your liking:
.ditto_paging {
border-top: 1px solid #ccc;
padding: 10px;
font-size: 86%;
color: black;
}
#ditto_pages .ditto_currentpage {
border: 1px solid black;
padding: 1px 5px 2px;
margin-right: 1px;
background-color: #008CBA;
color: #fff;
}
#ditto_pages .ditto_off {
border: 1px solid #ccc;
padding: 1px 5px 2px;
margin-right: 1px;
color: #ccc;
}
#ditto_pages a, #ditto_pages a:link, #ditto_pages a:visited {
border: 1px solid #008CBA;
padding: 1px 5px 2px;
margin-right: 1px;
text-decoration: none !important;
color: black;
}
#ditto_pages a:hover {
background-color: #fff;
color: #000;
}
Notes
When using pagination always call Ditto uncached (i.e. [!Ditto?!] not [[Ditto?]].)
Ditto normally generates a single-level list of documents. But sometimes this list can be too long to comfortably display on a web page. So Ditto lets you divide the list into pages that you can flip through with "Previous" and "Next" links. Each time you click one of these links the current web page will refresh and display a different "page" from the overall list of Ditto items.
Ditto does not provide automatically append a pagination template, so you can't get the Previous and Next links to appear merely by turning on pagination. Rather you must add the desired pagination placeholders to your document. (See the "Templates" section below for details.)
| Parameter | Description | Value Type | Legal Values | Default Value | Comments |
|---|---|---|---|---|---|
| &paginate | Turning on pagination causes Ditto to break the overall document list into segments of &display items, and to only display one segment (or "page") of results at a time. | boolean | Options: 0 - off 1 - on |
0 | "&display" has replaced "&summarize", and "&show" from previous versions. |
| &paginateAlwaysShowLinks |
When this parameter is set to "0" Ditto will leave the (or ) placeholders empty when the current page is the first (or last) page of results. When this parameter is set to "1", Ditto will continue to fill these placeholders with their (visible) text, even when the first/last page as been reached, although without the HTML links behind the text. |
Options: 0 - off 1 - on |
0 | ||
| &paginateSplitterCharacter |
The parameter specifies the text to be placed in the placeholder when pagination is on and the current page is not the first or last page of results. In all other cases this placeholder will be empty. |
A single character | Any valid character | The value specified in the 'button_splitter' field of the current language file. (The English file uses the "|" character.) | The current version does not limit this value to a single character, so in practice a multi-character text string may be used. |
| &tplPaginatePrevious |
This parameter lets you override the default "visible" text that Ditto places in the placeholder. See the "Templates" section for details. |
text string | (1) | The value specified in the prev field of the current language file. (The English file contains "< Previous ".) | This parameter was mis-named " &tplArchivePrevious" in the prior version of Ditto. |
| &tplPaginateNext | This parameter lets you override the default "visible" text that Ditto places in the placeholder. See the "Templates" section for details. | text string | (1) | The value specified in the next field of the current language file. (The English file contains "Next > ".) | This parameter was mis-named " &tplArchiveNext" in the prior version of Ditto. |
(1) &tpl can take three kinds of values:
- If the value does not begin with "@CODE" or "@FILE" then it is interpreted as the name of a chunk which contains the desired template.
- If the value begins with "@FILE", then it is interpreted as the pathname of a file which contains the desired template.
- If the value begins with "@CODE", then the value is interpreted as the template itself; right there in the snippet call.
Based on documentation work by Bill Fernandez