amministrazione downloads con paginazione dinamica
Autore
Messaggio
lucapuccetti Utente
93 Discussioni
24 giugno 2004 alle 13:25:01 Sulla falsariga di quello che ho fatto per le news ecco la modifica per l'amministrazione dei downloads
' Display the last downloads (by Date) ' IN : iTop (int) : number of results wanted ' : sSortedField (string) : field sorted ' : bAscSort (boolean) : if true = ASC sort, else DESC ' OUT : - Sub DisplayAdminTopDownloads(iTop, sSortedField, bAscSort) Dim oCn, oRs, rSQL, iLine, sSortDesc
Dim TotalPages, NumPerPage, CurrentPage, Number, nummin, nummax, numdiff, num, count, numextra set oCn=server.createobject("adodb.connection") oCn.open = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & Server.MapPath("/public/aspnuke/db/main.mdb") Set oRs = Server.CreateObject("ADODB.Recordset")
If request("NumPerPage") <> 0 then NumPerPage = Int(request("NumPerPage")) else NumPerPage = 10 end if If Request.QueryString("page") = "" then CurrentPage = 1 'We are on the first page Else CurrentPage = CInt(Request.QueryString("page")) End If
Select Case LCase(sSortedField) Case "dtitle" : sSortedField = sSortedField sSortDesc = GetTranslation("LANG_TITLE") Case "dhits" : sSortedField = sSortedField sSortDesc = GetTranslation("LANG_HITS") Case "ddate" : sSortedField = sSortedField sSortDesc = GetTranslation("LANG_DATE") Case Else : ' default value sSortedField = "dDate" bAscSort = False sSortDesc = GetTranslation("LANG_DATE") End Select
If iTop <> "" and iTop <> 0 Then rSQL = "SELECT TOP " & iTop & " dId, dTitle, dDate, dHits FROM downloads ORDER BY " & sSortedField Else rSQL = "SELECT dId, dTitle, dDate, dHits FROM downloads ORDER BY " & sSortedField End If
If Not bAscSort Then rSQL = rSQL & " DESC" sSortDesc = sSortDesc & " (DESC)" Else sSortDesc = sSortDesc & " (ASC)" End If
oRs.Open rSQL, oCn,3,3
Number = oRs.RecordCount If Not oRs.EOF Then oRs.MoveFirst oRs.PageSize = NumPerPage TotalPages = oRs.PageCount oRs.AbsolutePage = CurrentPage End If Dim ScriptName ScriptName = request.servervariables("ScriptName")
numdiff = NumPerPage - 1 numextra = CurrentPage * NumPerPage nummax = numextra if nummax > number Then nummax = number end if nummin = numextra - numdiff num=0 if CurrentPage > 1 then num=nummin-1 end if
'Print the recent Data response.write " <div align=""center"" style=""font-family: Verdana; font-size: 10px"">Pagina <b>" & CurrentPage & "</b> su un totale di <b>" & TotalPages & "</b> | Record <b>" & nummin & "</b> - <b>" & nummax & "</b> su un totale di <b>" & Number & "</b> <div>"
'Creating the paging numbers Dim ini, fim, a if CurrentPage > 5 and TotalPages > 10 then Response.write("<a href=" & ScriptName & "?NumPerPage=" & NumPerPage & "&page=1><font color=red><b>Inizio</b></a> " ) end if 'Display PREV page link, if appropriate If Not CurrentPage = 1 Then Response.Write "<a href='" & ScriptName & "?NumPerPage=" & NumPerPage & "&page=" & CurrentPage - 1 & "'><font color=666666><b>«</b></font></a> "
if TotalPages > 10 then
if CurrentPage > 5 then if TotalPages > (CurrentPage + 5) then ini = (CurrentPage - 4) fim = (CurrentPage + 5) else ini = (TotalPages - 9) fim = TotalPages end if else ini = 1 fim = 10 end if else ini=1 fim = TotalPages end if For a = ini to fim If a = Cint(request("page")) then Response.write( "<font color=red><b>" & a & "</b></font> ") Else Response.write("<a href=" & ScriptName & "?NumPerPage=" & NumPerPage & "&page=" & a &"><font color=666666><b>" & a & "</b></font></a>" & " " ) End if Next Else if TotalPages = 1 then Response.write "" Else Response.Write "<font color=red ><b>1</b></font> " End if if TotalPages > 10 then fim = 10 else fim = TotalPages end if For a = 2 to fim If a = Cint(request("page")) then Response.write( "<font color=red ><b>" & a & "</b></font> ") Else Response.write("<a href=" & ScriptName & "?NumPerPage=" & NumPerPage & "&page=" & a &"><font color=666666><b>" & a & "</b></font></a>" & " " ) End if Next End If 'Display NEXT page link, if appropriate If Not CurrentPage = TotalPages Then Response.Write " <a href='" & ScriptName & "?NumPerPage=" & NumPerPage & "&page=" & CurrentPage + 1 & "'><font color=666666><b>»</b></font></a>" Else Response.Write "" End If if CurrentPage < TotalPages - 5 and TotalPages > 10 then Response.write(" <a href=" & ScriptName & "?NumPerPage=" & NumPerPage & "&page=" & TotalPages &"><font color=red><b>Fine</b></a> " ) end if
oCn.Close Set oCn = Nothing Set oRs = Nothing End Sub
inserire il codice dentro il file includes/admin/downloads-inc.asp sostituendo la sub di default che è la prima che si incontra editando il file saluti
24 giugno 2004 alle 14:05:38 E' un buon lavoro, ma, vorrei suggerirti di usare il codice di AspNuke, ad esempio, l'apertura della connessione al database, invece di inserire la stringa di connessione con il ServerMapPath, puoi usare:
Set oCn = DBConnexion(DB_MAIN)
questo per mantenere un codice uniforme, il più possibile con AspNuke, anche i font e i colori, sono superflui, in quanto, è meglio usare ciò che è inserito nel default.css. Ciauzz DJ
--------------- A lavare la testa ai somari, ci si rimette l'acqua e il sapone!
24 giugno 2004 alle 21:33:37 Hai ragione purtroppo però c'è un problema di cursore che devo settare (con la connessione standard non va) e poi il driver jetoledb è più performante. Per quanto concerne la grafica è giustissimo quello che dici sai a volte si fa per risparmiare tempo adattando codice usato per altri lavori. cari saluti
25 giugno 2004 alle 08:47:51 La modifica l'ho già testata in locale, e funziona ugualmente bene, ovviamente, non si può applicare al settaggio di oRs, prorpio per il problema del cursore, comunque rimane sempre un buon lavoro. Ciauzz DJ
--------------- A lavare la testa ai somari, ci si rimette l'acqua e il sapone!
08 ottobre 2004 alle 00:18:12 Con la pagina dinamica di amministrazione delle news tutto mi funziona regolarmente. Con questa dei download mi fa vedere la prima pagina con 10 file e la seconda con due solamente. Nel database ne ho molti di più..... dove sbaglio?
verderamina Amatore
27 Discussioni
24 ottobre 2004 alle 23:37:33 up
lab82 Eliminato
0 Discussione
05 settembre 2007 alle 12:10:50 scusate, non mi riesce ad fare copia/incolla di questa paginazione ed non mi viene nemmeno con cit
Mi proteste dire come faccio ad copiarla o avete un file txt da scaricare ........
grazie.. luigi
Log in
Cerca
Sostieni AspNuke
Un piccolo gesto per aiutarci a mantenere AspNuke.it online
Promo
MusicWebItalia.it Video Testi Traduzioni Spot Colonne sonore Accordi e Spartiti gratis.
Visitatori
Visitatori Correnti : 395 Membri : 0
Anna
Iscritti
Utenti: 18940
Ultimo iscritto : glauco Lista iscritti Messaggi privati: 3373Commenti: 2210Immagini: 39Downloads: 144Articoli: 49Pagine: 101Siti web: 558Notizie: 180Sondaggi: 11Preferiti: 5684522Post sui forum: 51195Libro degli ospiti: 4Eventi: 7