Forum 

Forum AspNuke.it - Il tuo Portale OpenSource in ASP

Top five di una singola categoria

Autore Messaggio
Arago

Amatore
Amatore
33 Discussioni



Profilo - Arago
31 marzo 2003 alle 16:09:43 Profilo - AragoInvia un messaggio privato Rispondi quotando
ciao a tutti ...
Questo codice serve a visualizzare tutti gli articoli presenti in una categoria ...

Sub DisplayArticlesSearch(iCategory)
Dim oCn, oRs, rSQL, bFirst, iNbPages

bFirst = True

Set oCn = DBConnexion(DB_MAIN)

If iCategory = "" Then iCategory = 0
rSQL = "SELECT arId, arTitle, arAuthor, arDescription, arDate, count(apID) as NbPages FROM articles, articlespages, versions WHERE arID=apArticle AND arVersion=vID AND arValid=1 AND apValid=1 AND arCategory=" & iCategory
If sXMLVersion <> "" Then rSQL = rSQL & " AND vCode='" & sXMLVersion & "'"
rSQL = rSQL & " GROUP BY arID, arDate, arTitle, arAuthor, arDescription, arDate ORDER BY arDate"

Set oRs = DBRecordSet(oCn, rSQL)

If Not oRs.EOF Then
CreateTopTable "ArticlesByCategory", GetTranslation("LANG_ARTICLES")

While Not oRs.EOF
If Not bFirst Then Response.Write "<br><br>" & vbCRLF
iNbPages = oRs("NbPages")

If iNbPages > 0 Then
Response.Write "<b><a href=""" & sURLPage & "?id=" & oRs("arID") & """>" & CodeMessage(oRs("arTitle"), True) & "</a></b><br>" & vbCRLF
Else
Response.Write "<b>" & CodeMessage(oRs("arTitle"), True) & "</b><br>" & vbCRLF
End If
Response.Write "<span class=""small"">"
Response.Write Replace(Replace(GetTranslation("LANG_POST_DATE_BY"), "%1%", GetDateLitteralDDMMYYYYHHMMSS(StringToDate(oRs("arDate")))), "%2%", "<a href=""" & GLOBAL_SITE_PATH & GLOBAL_SITE_PROFILE_PAGE & "?id=" & Server.URLEncode(oRs("arAuthor")) & """>" & Server.HTMLEncode(oRs("arAuthor")) & "</a>") & " | " & vbCRLF
Response.Write " " & iNbPages & " "
If iNbPages > 1 Then
Response.Write GetTranslation("LANG_ARTICLE_PAGES")
Else
Response.Write GetTranslation("LANG_ARTICLE_PAGE")
End If
Response.Write "</span><br>" & vbCRLF
Response.Write oRs("arDescription") & vbCRLF

bFirst = False

oRs.MoveNext
WEnd

CreateBottomTable ""
End If

oCn.Close
Set oCn = Nothing
Set oRs = Nothing
End Sub

come posso modificarlo per far si che mi visualizzi solo gli ultimi 5 articoli inseriti nella categoria ?
grazie

Arago [lo]
---------------
www.arago.it
Arago

Amatore
Amatore
33 Discussioni



Profilo - Arago
02 aprile 2003 alle 13:12:32 Profilo - AragoInvia un messaggio privato Rispondi quotando
Ciao a tutti ...
anche stavolta .. haimè ... ho scoperto l'acqua calda :-)
ho modificato il codice in questo nel seguente modo quindi aggiungendo questa "nuova" sub routine :

Sub DisplayArticlesSearchhome(iCategory, iTop)
Dim oCn, oRs, rSQL, bFirst, iNbPages

bFirst = True

Set oCn = DBConnexion(DB_MAIN)

If iCategory = "" Then iCategory = 0

If iTop = "" Then iTop = 1

rSQL = "SELECT TOP " & iTop & " arId, arTitle, arAuthor, arDescription, arDate, count(apID) as NbPages FROM articles, articlespages, versions WHERE arID=apArticle AND arVersion=vID AND arValid=1 AND apValid=1 AND arCategory=" & iCategory
If sXMLVersion <> "" Then rSQL = rSQL & " AND vCode='" & sXMLVersion & "'"
rSQL = rSQL & " GROUP BY arID, arDate, arTitle, arAuthor, arDescription, arDate ORDER BY arDate DESC"

Set oRs = DBRecordSet(oCn, rSQL)

If Not oRs.EOF Then
CreateTopTable "ArticlesByCategory", GetTranslation("LANG_ARTICLES")

While Not oRs.EOF

If Not bFirst Then Response.Write "<br><br>" & vbCRLF
iNbPages = oRs("NbPages")

If iNbPages > 0 Then
Response.Write "<b><a href=""" & GLOBAL_SITE_PATH & "articles.asp" & "?id=" & oRs("arID") & """>" & CodeMessage(oRs("arTitle"), True) & "</a></b><br>" & vbCRLF
Else
Response.Write "<b>" & CodeMessage(oRs("arTitle"), True) & "</b><br>" & vbCRLF
End If
Response.Write "<span class=""small"">"
Response.Write Replace(Replace(GetTranslation("LANG_POST_DATE_BY"), "%1%", GetDateLitteralDDMMYYYYHHMMSS(StringToDate(oRs("arDate")))), "%2%", "<a href=""" & GLOBAL_SITE_PATH & GLOBAL_SITE_PROFILE_PAGE & "?id=" & Server.URLEncode(oRs("arAuthor")) & """>" & Server.HTMLEncode(oRs("arAuthor")) & "</a>") & " | " & vbCRLF
Response.Write " " & iNbPages & " "
If iNbPages > 1 Then
Response.Write GetTranslation("LANG_ARTICLE_PAGES")
Else
Response.Write GetTranslation("LANG_ARTICLE_PAGE")
End If
Response.Write "</span><br>" & vbCRLF
Response.Write oRs("arDescription") & vbCRLF

bFirst = False

oRs.MoveNext
WEnd

CreateBottomTable ""
End If

oCn.Close
Set oCn = Nothing
Set oRs = Nothing
End Sub


non so se vi tornerà utile ... ma a me è servito per dare un effetto di visializzazione notizie in stile ansa su un sito di archeologia.

Arago [lo]
---------------
www.arago.it

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 : 131
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: 425 Notizie: 180 Sondaggi: 11 Preferiti: 200660 Post sui forum: 51195 Libro degli ospiti: 4 Eventi: 7

Versioni

Temi