14
Aug
2006
NinjaFish.CommunityServer
[Update] Due to something else I'm working on, I've shortened the name of the control to just "EntryDate".
Something that I'd been meaning to do was to take that code I came up with for parsing out the Community Server post dates and distill it down to a web custom control. Well, I've finally gotten around to it.
The control is called EntryDate, and inherits from the CS WeblogThemedControl. This means that it uses the same skinning motif as the rest of the built-in CS blog controls, so you drop a reference to EntryDate where you want it and fill out the UI details on Skin-EntryDate.ascx. Here is an example pulled from my own blog skin:
Skin-EntryView.ascx
<%@ Control Language="C#" %>
<%@ Import Namespace="CommunityServer.Components" %>
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
<%@ Register TagPrefix="Blog" Namespace="CommunityServer.Blogs.Controls" Assembly="CommunityServer.Blogs" %>
<%@ Register TagPrefix="nf" Namespace="NinjaFish.CommunityServer.Controls" Assembly="NinjaFish.CommunityServer" %>
<div class="entry-view">
<nf:EntryDate runat="server" />
<h1 class="entry-title"><asp:Literal ID="EntryTitle" runat="server" /></h1>
<asp:Literal ID="EntryBody" runat="server" />
<div class="entry-footer">
<div class="entry-published-date">
<CS:ResourceControl ResourceName="Feedback_FilterPublished" runat="server" /> <asp:Literal ID="EntryDesc" Text="Perma Link" runat="server" />
</div>
<asp:HyperLink ID="EditLink" Visible="False" runat="server" /> <Blog:CategoryTagControl ID="Tags" runat="server" />
<Blog:DownloadAttachmentLink ID="Attachment" runat="server" />
</div>
</div>
The tag that does the fun bit is <nf:TemplatedEntryDate runat="server" />, while the contents of the skin file can be found below:
Skin-EntryDate.ascx
<%@ Control Language="C#" %>
<span class="entry-date">
<asp:Label ID="EntryDay" CssClass="entry-day" runat="server" />
<asp:Label ID="EntryMonth" CssClass="entry-month" runat="server" />
<asp:Label ID="EntryYear" CssClass="entry-year" runat="server" />
</span>
That's it! The look and feel of the date is up to you; you don't even have to use my markup, and the control supports attributes to render different date formats for each part of the date. More details in the readme file.
Also, because I was too lazy to strip it out and I guess it works as intended, the <CS:Head> replacement I spoke about in this post is included, as well.
You can download the assembly and source here.