Forum 

Forum AspNuke.it - Il tuo Portale OpenSource in ASP

amministrazione downloads con paginazione dinamica

Autore Messaggio
lucapuccetti

Utente
Utente
93 Discussioni



Profilo - lucapuccetti
24 giugno 2004 alle 13:25:01 Profilo - lucapuccettiInvia un messaggio privato Rispondi quotando
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

CreateTopTable "TopDownloads", GetTranslation("LANG_TOP") & " " & iTop & " - " & GetTranslation("LANG_DOWNLOADS") & " | <span class=""small"">" & Replace(GetTranslation("LANG_SORT_BY"), "%1%", sSortDesc) & "</span>"

'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




Response.Write GLOBAL_SITE_SUBTABLE & vbCRLF
Response.Write " <tr class=""tablelinemain"">" & vbCRLF
Response.Write " <td>"
SortMenu GetTranslation("LANG_TITLE"), "dTitle", sSortedField, bAscSort
Response.Write "</td>" & vbCRLF
Response.Write " <td width=""80"" align=""center"">"
SortMenu GetTranslation("LANG_DATE"), "dDate", sSortedField, bAscSort
Response.Write "</td>" & vbCRLF
Response.Write " <td width=""80"" align=""center"">"
SortMenu GetTranslation("LANG_HITS"), "dHits", sSortedField, bAscSort
Response.Write "</td>" & vbCRLF
Response.Write " <td width=""100"" align=""center"">" & GetTranslation("LANG_ACTIONS") & "</td>" & vbCRLF
Response.Write " </tr>" & vbCRLF
If Not oRs.EOF Then
iLine = 1
While Not oRs.EOF and count < oRs.PageSize
count=count+1
num=num+1
Response.Write " <tr class=""tableline" & iLine & """>" & vbCRLF
Response.Write " <td>" & Server.HTMLEncode(oRs("dTitle")) & "</td>" & vbCRLF
Response.Write " <td align=""center"">" & GetDateDDMMYY(StringToDate(oRs("dDate"))) & "</td>" & vbCRLF
Response.Write " <td align=""center"">" & oRs("dHits") & "</td>" & vbCRLF
Response.Write " <td align=""center"">" & vbCRLF
MenuAdmin(oRs("dID"))
Response.Write " </td>" & vbCRLF
Response.Write " </tr>" & vbCRLF

iLine = 1 + ((iLine-1) XOR 1)
oRs.MoveNext
WEnd
End If
Response.Write " <tr class=""tablelinemain"">" & vbCRLF
Response.Write " <td colspan=""4""><a href=""" & sURLPage & "?do=new"">" & GetTranslation("LANG_ADD") & " - " & GetTranslation("LANG_DOWNLOAD") & "</a></td>" & vbCRLF
Response.Write " </tr>" & vbCRLF
Response.Write "</table>" & vbCRLF
CreateBottomTable ""

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

Luca
djveleno

Amministratore

Esperto
Esperto
1025 Discussioni



Profilo - djveleno
24 giugno 2004 alle 14:05:38 Profilo - djvelenoInvia un messaggio privato Rispondi quotando
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!

http://aspnuke208.somee.com/Default.asp

lucapuccetti

Utente
Utente
93 Discussioni



Profilo - lucapuccetti
24 giugno 2004 alle 21:33:37 Profilo - lucapuccettiInvia un messaggio privato Rispondi quotando
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

Luca
djveleno

Amministratore

Esperto
Esperto
1025 Discussioni



Profilo - djveleno
25 giugno 2004 alle 08:47:51 Profilo - djvelenoInvia un messaggio privato Rispondi quotando
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!

http://aspnuke208.somee.com/Default.asp

verderamina

Amatore
Amatore
27 Discussioni



Profilo - verderamina
08 ottobre 2004 alle 00:18:12 Profilo - verderaminaInvia un messaggio privato Rispondi quotando
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
Amatore
27 Discussioni



Profilo - verderamina
24 ottobre 2004 alle 23:37:33 Profilo - verderaminaInvia un messaggio privato Rispondi quotando
up
lab82

Eliminato
Eliminato
0 Discussione



Profilo - lab82
05 settembre 2007 alle 12:10:50 Profilo - lab82Invia un messaggio privato Rispondi quotando
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
[lo]

Log in

Login
Password
Memorizza i tuoi dati:

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 offline Anna

Iscritti

 Utenti: 18940
Ultimo iscritto : glauco
Lista iscritti
Messaggi privati: 3373 Commenti: 2210 Immagini: 39 Downloads: 144 Articoli: 49 Pagine: 101 Siti web: 558 Notizie: 180 Sondaggi: 11 Preferiti: 5684522 Post sui forum: 51195 Libro degli ospiti: 4 Eventi: 7

Versioni

Temi