· 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.

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.

Back to Blog

Related Posts

View All Posts »
Community Server Tweaks, Latest Posts

Community Server Tweaks, Latest Posts

Learn how to enhance your Community Server site user experience with smart tweaks like displaying last post author and linking directly to the latest post in this guide. Make your forum more engaging!

HTTP Compression for IIS 6.0

HTTP Compression for IIS 6.0

Learn how to set up HTTP Compression on IIS 6 to boost website performance. Find out if the difference is truly noticeable after enabling compression!

Excellent Programmer!

Excellent Programmer!

Looking for an excellent programmer with mad skills? Look no further! Find out more about our exceptional developer here. #programming #techtalent