Template:Extension DPL continue2

From Terraria Wiki
Jump to navigation Jump to search

Scroll through large DPL sets using DPL_arg5 as an offset parameter.

DPL can (at time of writing) only return 100 results. If you need to return larger data sets, then this template can be used in your DPL query to create start, back and next links to scroll through the result set. The template uses the value of DPL_arg5 to specify the current offset in the data set. The "count" is used to specify how big each jump in the offset should be. The template automatically copies DPL_arg 1 to 4 if they have already been specified and includes these in the next scroll request.

Information.svg
Note: This template should be used instead of Template:Extension DPL continue where DPL queries are not ordered by title (e.g. where ordering is done by page views). It is also more robust in that it can handle URL parameters other than in English sensibly.


An example of how this is used is shown below. Simply copy the text below into the end of your query. Note that you will need to change the DPL_count value to 100 (instead of 10) for large sets.

<dpl>
...
offset		= {%DPL_arg5:0%}
count		= {%DPL_count:10%}
resultsheader	= ²{Extension DPL continue2¦pages=%PAGES%¦total=%TOTALPAGES%¦anchor=MyTestAnchor¦count={%DPL_count:10%}¦currentoffset={%DPL_arg5:0%} }²\n
resultsfooter	= ²{Extension DPL continue2¦pages=%PAGES%¦total=%TOTALPAGES%¦anchor=MyTestAnchor¦count={%DPL_count:10%}¦currentoffset={%DPL_arg5:0%} }² %DPLTIME%\n
scroll		= yes
</dpl>

The count is the number of items to display, and this is also passed to the template to define the size to the next step.

The template simply calculates the new offset by adding/substracting the count from the currentoffset. The totalpages and pages are passed in to determine the end points where the offset can no longer be iterated. You may be wondering why we don't use DPL_offset for the offset - the reason is that this affects all DPL on the page - that means that if you have a query that calls DPL that itself calls phantom DPL, the phantom DPL will also be affected by the offset value.