· Chris Hammond
Last Updated
Community Server Latest Post Changes
Learn how to modify homepage controls to display latest post, author, and forum info on www.sccaforums.com using C# scripting for better user engagement.
So I needed to modify the way the controls on the right of the homepage were showing up. So they linked to the latest post, showed the author, and the forum that they were posted in. Here's how I did it for www.sccaforums.com, which is using 2.0
Near the top of your default.aspx page add
int getPageNumber(int replies) { int page = 1; if (replies > 15) { page = 1 + replies /15; } return page; } int getPageNumber(int replies) { int page = 1; if (replies > 15) { page = 1 + replies /15; } return page; }
<script language="C#" runat="server">
int getPageNumber(int replies)
{
int page = 1;
if (replies > 15)
{
page = 1 + replies /15;
}
return page;
}
</script>
And then on the controls use the following to display all the information I was looking for. Just after
<ItemTemplate>
<div class="CommonSidebarContentItem">
insert
<strong><a href="<%# ForumUrls.Instance().PostPaged((int) DataBinder.Eval(Container.DataItem, "MostRecentPostID"), getPageNumber((int)DataBinder.Eval(Container.DataItem, "replies")))%>"><%# DataBinder.Eval(Container.DataItem, "Subject").ToString() %></a>
</strong>
- <strong><%# DataBinder.Eval(Container.DataItem, "MostRecentPostAuthor") %></strong><br>
<a href="<%# ForumUrls.Instance().Forum( ((Thread) Container.DataItem).SectionID ) %>">
<%# DataBinder.Eval(Container.DataItem, "Forum.Name") %>
</a>
This is all pretty similiar to the "latest post control" I released for 1.1, but some of the functions changed locations so that control no longer works without modification.