Technical References - [shownext]

[shownext] is a special context used to create links (or more accurately, the sets of ranges of found items - it's up to you to make them into links) to the next or previous sets of results.

Put [shownext] inside the search context, but not inside [founditems]. To sucessfully use [shownext], you need to add some matching parameters in the [search] context, as shown in the example.


[shownext] is a looping type of context. It will repeat until all the sets of ranges are accounted for. In this example, we've used a pipe character to separate the sets. Each repeat of the [shownext] will end in the pipe character, separating the links from each other. There are three different [shownext] contexts to handle the before, current, and after sets of ranges.

Example for a file named "states.dna"
<!--HAS_WEBDNA_TAGS-->

[search db=states.db&geSTATEdata=1&refsort=1&max=10&startat=[starthere]]

[shownext position=begin]
<a href="states.dna?state=[url][state][/url]&starthere=[start]"> [start]-[end]</a> |
[/shownext]
[shownext position=middle]
<b>[start]-[end]</b> |
[/shownext]
[shownext position=end]
<a href="states.dna?state=[url][state][/url]&starthere=[start]"> [start]-[end]</a> |
[/shownext]
<br>
[founditems]-[state]<br>[/founditems]

[/search]

your database "states.db" should look like
ref    state
1 Alabama
2 Alaska
3 American Samoa
4 Arizona
5 Arkansas
6 California
7 Colorado
8 Connecticut
9 Delaware
10 District of Columbia
11 Florida
...

Explanation of the Example
The [search] context uses a variable for [state]. Imagine that on the previous page the user had a choice of states to click on. If they click on Texas, then we need to remember Texas and carry it through to the rest of the pages, because each page performs the search all over again. This is why we include state=[state] in the Shownext links. It will resolve to state=Texas, and the search for the next pages will be correct.

[search] also uses startat=[starthere], and the shownext links use starthere=[start]. This is perhaps the most confusing part of the shownext context. startat= is part of the search context and must be entered as such. [start] is a special tag used in the [shownext] context, and reveals the starting index for a given range of records. In our example, [starthere] is our own, made-up name for a variable we will use to pass the value of [start] on to the next page, where it lands in the search. We could just have easily used [elephant], or [start] or [startat]. The choice is yours, but the idea is to not add more confusion.

Shownext-specific parameters for the Search Context
startat This specifies where, in the total search that is performed, the current page's worth of found items will begin. If it is missing or invalid (i.e., the raw code [starthere] appears), it will start at the beginning.
max(not to be confused with the max in the shownext context) This specifies how many in each set of records.
Parameters specific to the ShowNext context
positionbegin - Displays the ranges ([start]-[end]) for records before the ones currently displayed inside the [founditems] loop
middle - Displays the ranges for records currently displayed inside the [founditems] loop (usually not as links, but perhaps bolded or styled in some way to show the user that this is the range they are currently seeing.)
end - Displays the ranges for records after the ones currently displayed inside the [founditems] loop
parameter not used - Defaults to show the entire range of before and after, skipping the current (middle) range.
max(not to be confused with the max in the search context) this specifies how many sets of ranges to display. If set to 1, then you can show a simple "next" link.
Tags available inside the ShowNext context
[start]The index position of the first item that will be displayed in this range of found items
[end]The index position of the last item that will be displayed in this range of found items
[searchstring] All search parameters used to find this "chunk" of items in the range [Start] - [End]. However, this tag is not compatible with the search context. It is a tag from early versions of WebDNA, when using the less secure URL string or formvariables to perform a search, and for security reasons, is not a recommended technique today.

In modern usage, you will construct your URL in the shownext context to contain only those variables necessary to perform the search, plus the starting value. See example above.


You will find sophisticated examples at "a [shownext] example", "another [shownext] example" and "an example of application for [shownext]"

You can also use the WebDNA flexibility to find an alternative solution, like this alternative to [shownext] code. Terry Wilson

DOWNLOAD WEBDNA NOW!

Top Articles:

F.A.Q

A compilation of some user's questions...

WebDNA reference

A list of all WebDNA instructions...

WebDNA Modules

A list of the currently available modules...

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...

WebDNA Libraries

A list of available libraries for WebDNA...

Technical Change History

This Technical Change History provides a reverse chronological list of WebDNA changes...

Related Readings:

[replacefounditems]

Replaces each found record in a database with the new field values...

[exclusivelock]

Prevents other threads from simultaneously accessing a group of databases...

[copyfolder]

Copy a folder and all its contenton your webspace...

[switch]

Executes the WebDNA inside the only [case] context which matches the given value...

[founditems]

[founditems]...

[hideif]

[HideIf Comparison]Hide This HTML[/HideIf]...