First time here? You may want to check out the blog archive, subscribe to the RSS feed, sign up for free email updates, or follow me on Twitter. Thanks for visiting!

Format Date Time with suffix like 1st, 2nd, 3rd, 4th

Recently some client of our DNN blog module requested a customized feature, he wanted to out the posted time of SunBlogNuke in a format that included the two letter suffix added to the day number, like "December 25th, 2009" as opposed to "December 25, 2009". After some investigation, it seems this is not supported out of the box (not surprising really). Finally I found the MarkGwilliam’s post (How To Append 'st', 'nd', 'rd' or 'th' To Day Numbers in Dates) which provided a ".NET Framework friendly" to implement this behavior and therefore offers good reuse value and is intuitive for .NET developers to use. I thought that is what we want and then extended it in our customized way which allows SunBlogNuke developers to consume the code more easily and flexible. Now I shared the VB.Net Function below and hope it helps if you also have the similar requirement:

Protected Function FormatPostedTimeWithDayNumberSuffix(Optional ByVal format As String = "MMMM d{0}, yyyy") As String
    Dim dateTime As DateTime = Date.Parse(Entry.PostedTime)
    If Not Null.IsNull(dateTime) Then
        Dim formatTime As String = dateTime.ToString(format)

        Dim day As Integer = dateTime.Day
        Dim dayFormat As String = String.Empty
        Select Case day
            Case 1, 21, 31
                dayFormat = "st"
            Case 2, 22
                dayFormat = "nd"
            Case 3, 23
                dayFormat = "rd"
            Case Else
                dayFormat = "th"
        End Select

        Return String.Format(formatTime, dayFormat)
    End If

    Return Entry.PostedTime
End Function

If you have more better or elegant solution appreciate your comments here. Thanks a lot.

Holiday Sale for Ultimate DNN Blog Module::SunBlogNuke - Up to 40% OFF

Christmas Gift for Ultimate DNN Blog Module::SunBlogNuke Holiday Sale - Up To 40% Off Ultimate DNN Blog Module :: SunBlogNuke. Save Big, Spend Little. For limited time(12/23/2009 – 1/4/2010), you can save on the SunBlogNuke Subscriptions giving you full access to our blog module for an entire year.  Full details are on www.sunblognuke.com.

Why not buy now when you would like to own it?  Enjoy blogging and happy holidays!

Note that the Discount code is “Christmas”, which is not case sensitive.

Move SunBlogNuke Web Site to Another Hosting Service

In order to enhance the website traffic for SunBlogNuke website, we get started to move our website to a more excellent hosting service and modify the domain name into SunBlogNuke.com. Today it have been done well and is available.  Congratulations :)

PS: SunBlogNuke v2.6.5 also is released today, with fixing some following issues:

Please get it from here.

Compress CSS in DNN to Enhance Website Performance

Recently we tried to optimize our DNN website SunBlogNuke for super speed and had an opportunity to play around with UnloadCSS skinobject from Timo Breumelhof. What a nifty little tool to use for your front-end performance optimization. Thanks Timo!

Also it inspired us and our CompressCSS skinobject was born out. So you may say that CompressCSS is the extended and optimized version of UnloadCSS and I agree with you. Not only does it unload any unnecessary CSS files but also compress any existing CSS files thereby improving more performance and extending more flexibility into your DNN website. Let’s show you the magic of CompressCSS below.

Why should you utilize it?

As the Cuong Dang mentioned in his post, there are many unnecessary CSS files get loaded within the DNN framework (not to mention some not-so-good practices in CSS coding techniques within these files) that a web designer wants to take control of. Some one may ask whether there is a way to improve that? Fortunately, CompressCss allows you to unload any CSS file that the DotNetNuke® framework injects and compresses any existing CSS files in the head of the page; it will reduce the number of HTTP requests from a browser and minify the size of the downloaded file thereby improving load times apparently.

In conclusion, you can improve your front-end performance and make the speed of your DNN page load faster with CompressCSS.

How does it work?

First let’s cover the two below flows (or process) that will be taken place when you utilize our skinobject CompressCSS:

Unload Process - "Unload" all or some of the CSS files DotNetNuke includes in the Head of the page by default, such as Default.css, Module.css or Portal.css. You can pass the path to the file you don't want loaded as a regular expression which means you can unload multiple CSS files with just one statement.

Minify Process - Removing unnecessary characters from style code to reduce its size thereby improving load times. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab).

You can apply it in your DNN website with the following steps:

1) Download the zip attachment and unzip it in your local machine.

2) Copy the assemble DnnSun.OptimizerToolkit.dll into the bin folder of your DNN webiste.

3) Copy the CompressCss.ascx & CompressCss.ascx.vb into the skin control folder, which should be $yourweb/admin/Skins.

4) Open your web.config file, find out the <httpHandlers> section and insert the line below:

<httpHandlers>
<
add verb="*" path="css.axd" type="DnnSun.OptimizerToolkit.CssHandler, DnnSun.OptimizerToolkit" validate="false" />
<!--
Other httpHandlers -->
</
httpHandlers>

5) Open your skin file (like index.ascx), register the skinobject in the head and insert it in the bottom. Then it may look like as follows:

<%@ Register TagPrefix="dnn" TagName="COMPRESSCSS" Src="~/Admin/Skins/CompressCss.ascx" %>
<!-- Other Tags -->
<dnn:COMPRESSCSS ID="dnnCOMPRESSCSS" runat="server"
RemoveFileNames="/Portals/_default/Containers/MinimalExtropy/container.css" />

You can download the install zip & skin sample from the attachment in the bottom of this post.

The only attribute you need to care for:

Attribute

Values

Default

Description

RemoveFileNames

Examples:

  • "Default.css" to not load Default.css
  • "DesktopModules/xxModule/Module.css" to not load a specific modules.css
  • "Module.css" to not load any Modules.css file
  • "/" will not load any CSS files
  • "Default.css, Portal.css" will not load Default.css & Portal.css

Empty String

Comma separated list of Filenames you don't want to load (You can use a regular expression if needed)

What is the advantage?

The advantage is that this is not a core hack and the excellent CompressCSS skinobject can be configured per skin, not for the whole installation. The links are removed on the server side, so they never appear in the source. And the designer can build the more flexibility, readable and maintainable style without worrying about the file size.

To be continued…

This solution is a good start and you can extend it with more killer features. For instance, we our blog team tried to combine some specific or unnecessary CSS files into only one style file so that it will eventually minimize HTTP Requests as we expected. But we found out that there is a style path issue like background property and can’t fix it now. Hope you guys provide some clues. We appreciate any helps.

Attachment: CompressCss_v1.zip

The Ultimate DNN Blog Module::SunBlogNuke Tutorial

Today we are glad to announce that we have completed the initial version of SunBlogNuke Guidelines, which includes the Ultimate DNN Blog Module::SunBlogNuke tutorial. If you are our clients or interested in what cool features SunBlogNuke have implemented, please get it from our download page. With it you should find everything you need to get up and running with SunBlogNuke as well as in depth information on the more advanced options. The documentation has been divided into sections to keep it easy to navigate and maintain, including installation, upgrade, configuration and other tutorials. Later we will continue to enhance it in more details.

Good luck and happy writing.

The SunBlogNuke team