Author |
Topic |
|
StephenD
Senior Member
Australia
1044 Posts |
Posted - 04 December 2003 : 22:37:08
|
I've been playing around with David's Portal Mod and I would like the sub DisplayCategories to display new articles in the following manner:
4 Dec Test article 1 4 Dec Test article 2 2 Dec Test article 3 .... etc in the next fontsize down too
I know I would have to add: strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_DATE " this in somewhere and modify the date output to that format.
... Well, I haven't really got very far at all have I
I like the idea though and if anyone can assist it would be sincerely appreciated. |
|
StephenD
Senior Member
Australia
1044 Posts |
Posted - 04 December 2003 : 23:10:36
|
Yikes! I nearly got it:
call StartTable(Width, rsCatList.Fields("CAT_TITLE").Value)
strSql = "SELECT "
strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_ID, "
strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_TITLE, "
strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_DATE "
strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
strSql = strSql & "WHERE " & strTablePrefix & "CMS_CONTENT.CAT_ID = " & lCategoryID & " "
strSql = strSql & "ORDER BY " & strTablePrefix & "CMS_CONTENT.CONT_LAST_EDIT DESC"
set rsContList = Server.CreateObject("ADODB.Recordset")
set rsContent = my_Conn.Execute(strSql)
rsContList.CursorLocation = adUseClient
rsContList.Open strSql, my_Conn
do while NOT rsContList.EOF and rsContList.AbsolutePosition <= CInt(lItemsToDisplay)
Response.Write " "& ChkDate(rsContent.Fields("CONT_DATE").Value,"</b>",true) &"<DIV class=""listitem2""><a href="""& Request.ServerVariables("SCRIPTNAME") &"?ContentID="& rsContList.Fields("CONT_ID").Value &"&CategoryID="& lCategoryID &""">"& rsContList.Fields("CONT_TITLE").value &"</a></DIV>"
rsContList.MoveNext
loop
The red is my new code. My DIV looks like this:
.listitem2
{display: list-item; list-style: square inside; font: 11px/100% <%= strDefaultFontFace %>;}
This is what it looks like:
Anyone know how to prune the date to 'Dec 2' ? |
|
|
StephenD
Senior Member
Australia
1044 Posts |
Posted - 04 December 2003 : 23:54:40
|
I've cleaned it up a bit more and removed the square bullet:
Response.Write "<DIV class=""listitem2"">"& ChkDate(rsContent.Fields("CONT_DATE").Value,"</b>",true) & " " & "<a href="""& Request.ServerVariables("SCRIPTNAME") &"?ContentID="& rsContList.Fields("CONT_ID").Value &"&CategoryID="& lCategoryID &""">"& rsContList.Fields("CONT_TITLE").value &"</a></DIV>"
See previous image in post. Just need the date trimmed now. |
|
|
StephenD
Senior Member
Australia
1044 Posts |
Posted - 05 December 2003 : 02:08:58
|
Don't know if I'm on the right track or not but I've been trying to use this function instead of ChkDate:
Function GetShortDate(fdate)
StringVar = fdate
YearVar = Left(StringVar, 4)
StringVar = Replace(StringVar, YearVar, "")
MonthNumber = Left(StringVar, 2)
MonthVar = MonthName(MonthNumber)
StringVar = Replace(StringVar, MonthNumber, "")
DayVar = Fix(StringVar)
FormattedDate = DayVar & " " & MonthVar
GetShortDate = FormattedDate
End Function When I try to use it I get this error:
Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment: 'GetShortDate'
So I don't know where to go from here.
|
|
|
StephenD
Senior Member
Australia
1044 Posts |
Posted - 05 December 2003 : 03:18:00
|
Alright ... by putting in this bit:
Response.Write "<DIV class=""listitem2"">"& ChkDate(rsContent.Fields("CONT_DATE").Value,"",false) & " " & "<a href="""& Request.ServerVariables("SCRIPTNAME") &"?ContentID="& rsContList.Fields("CONT_ID").Value &"&CategoryID="& lCategoryID &""">"& rsContList.Fields("CONT_TITLE").value &"</a></DIV>" it gets rid of the time and displays it like this: 05 Dec 2003 Test Article 2
How do I get rid of the year? |
|
|
StephenD
Senior Member
Australia
1044 Posts |
Posted - 05 December 2003 : 04:36:19
|
Finally got it.
Created this function which I put at the bottom of portal.asp:
Function RemoveYear(pString)
fString = trim(pString)
fString = Replace(fString, "2002", "")
fString = Replace(fString, "2003", "")
fString = Replace(fString, "2004", "")
RemoveYear = fString
end Function
Changed my line to:
Response.Write "<DIV class=""listitem2"">"& RemoveYear(ChkDate(rsContent.Fields("CONT_DATE").Value,"",false)) & " " & "<a href="""& Request.ServerVariables("SCRIPTNAME") &"?ContentID="& rsContList.Fields("CONT_ID").Value &"&CategoryID="& lCategoryID &""">"& rsContList.Fields("CONT_TITLE").value &"</a></DIV>"
Check out the image above to see how it looks now. |
|
|
StephenD
Senior Member
Australia
1044 Posts |
Posted - 05 December 2003 : 05:32:27
|
Couple of other modifications to make:
call StartTable(Width, rsCatList.Fields("CAT_TITLE").Value)
strSql = "SELECT "
strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_ID, "
strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_TITLE, "
strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_DATE "
strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
strSql = strSql & "WHERE " & strTablePrefix & "CMS_CONTENT.CAT_ID = " & lCategoryID & " "
strSql = strSql & "ORDER BY " & strTablePrefix & "CMS_CONTENT.CONT_LAST_EDIT DESC"
set rsContList = Server.CreateObject("ADODB.Recordset")
set rsContent = my_Conn.Execute(strSql)
rsContList.CursorLocation = adUseClient
rsContList.Open strSql, my_Conn
do while NOT rsContList.EOF and rsContList.AbsolutePosition <= CInt(lItemsToDisplay)
If StrComp(rsContList.Fields("CONT_DATE").Value, rsContList.Fields("CONT_LAST_EDIT").Value, vbTextCompare) <> 0 then
Response.Write "<DIV class=""listitem2"">"& RemoveYear(ChkDate(rsContList.Fields("CONT_LAST_EDIT").Value,"",false)) & " " & "<a href="""& Request.ServerVariables("SCRIPTNAME") &"?ContentID="& rsContList.Fields("CONT_ID").Value &"&CategoryID="& lCategoryID & """>"& rsContList.Fields("CONT_TITLE").value & "</a></DIV>"
else
Response.Write "<DIV class=""listitem2"">"& RemoveYear(ChkDate(rsContent.Fields("CONT_DATE").Value,"",false)) & " " & "<a href="""& Request.ServerVariables("SCRIPTNAME") &"?ContentID="& rsContList.Fields("CONT_ID").Value &"&CategoryID="& lCategoryID &""">"& rsContList.Fields("CONT_TITLE").value & " " & getCurrentIcon(strIconStarSilver,"New Article","align=""absmiddle""") &"</a></DIV>"
end if
rsContList.MoveNext
rsContent.MoveNext
loop
if rsContList.RecordCount > CInt(lItemsToDisplay) then
Response.Write "<a href="""& sThisPage &"?CategoryID="& lCategoryID &""">more "& rsCatList.Fields("CAT_TITLE").value &"....</a>"
end if
set rsContList = nothing
set rsContent = nothing
call EndTable()
Blue modification will display an icon with mouseover(in my case - small silver star) to show a new article. It will also display the last edit date instead of posted date if an article has been updated. |
Edited by - StephenD on 10 December 2003 11:38:17 |
|
|
|
Topic |
|