PDA

View Full Version : [VBscript] DD "CSS Pagination Links" menu generator



chopsy
07-04-2007, 10:43 PM
1) CODE TITLE: DD "CSS Pagination Links" menu generator

2) AUTHOR NAME/NOTES: Anil Chopra

3) DESCRIPTION:
Server side code to generate a navigation menu using the CSS formatting from the CSS Pagination Links script on DD.

Simple (basic) bit of VBscript to generate pagination/navigation links suitable for online galleries where the directory structure uses a standard format (gallery01/, gallery02/, gallery03/, etc). This code quickly creates the HTML list, including hyperlinks, using the class statements defined in the CSS pagination links script.

The function uses the following three arguments
- MyNumber - Where this page fits in this sequence of pages
- endNumber - Total number of pages in this sequence
- galleryName - common prefix for all gallery directory names (assumes all directory names start with galleryname and end in MyNumber)

Script:
<&#37;
Function PrintPagination(MyNumber, endNumber, galleryName)
response.write "<div class=" & chr(34) & "pagination" & chr(34) & ">" & vbcrlf
if MyNumber = 1 then
response.write "<li class=" & chr(34) & "disablepage" & chr(34) & "><<</li>" & vbcrlf
else
response.write "<li class=" & chr(34) & "nextpage" & chr(34) & "><a href=" &chr(34) & "/" & galleryname & MyNumber-1 & chr(34) & "><<</a></li>" & vbcrlf
end if
for i = 1 to endNumber
if i = MyNumber then
response.write "<li class=" & chr(34) & "currentpage" & chr(34) & ">" & i & "</li>" & vbcrlf
else
response.write "<li><a href=" &chr(34) & "/" & galleryname & i & chr(34) & ">" & i & "</a></li>" & vbcrlf
end if
next
if MyNumber = endNumber then
response.write "<li class=" & chr(34) & "disablepage" & chr(34) & ">>></li>" & vbcrlf
else
response.write "<li class=" & chr(34) & "nextpage" & chr(34) & "><a href=" &chr(34) & "/" & galleryname & MyNumber+1 & chr(34) & ">>></a></li>" & vbcrlf
end if
response.write "</div>" & vbcrlf
end Function
%>


To insert the code anywhere in your page, call the function using

<%
PrintPagination MyNumber, endNumber, "galleryName"
%>

i.e
<%
PrintPagination 3, 11, "images"
%>

This will create a navigation bar of 11 elements with element 3 highlighted as the currentpage. Also, adds the correct links for previous and next.

This script really comes in useful when you have to add new galleries to your sequence - updating all existing files with the new navigation links is as simple as changing the numbers in the above statement.

Site running code: http://www.fuortesventure.co.uk/Individual-01/
See bottom right....