Go Back

Sitefinity: Displaying news for current month only.

I have been working on a site called Mega-Scene over the last couple of months. Mega-Scene started out as a print magazine distributed in Greenville, SC and is launching a web version at www.mega-scene.com. This is my first big project with Sitefinity, and I gain a lot of experience using the News Control to display articles.

The default Sitefinity front end news controls displays all news including previous months. The client requested a way to display only the current month. I needed a quick solution without modifying the control; I can go back later and write a custom control to meet this requirement later since I am the site Web Master.

To meet this requirement of current month I played around with filters under the Advanced Tab. The Filter Expression is a basic Sql Where statement. (AND gate).

Both conditions must be true to produce an output.

The default settings for FilterExpression:
Publication_Date <= "#now" AND Expiration_Date > "#now"

Settings for July 2009 articles only.
Publication_Date >= "7/1/2009" AND Expiration_Date > "#now"
The control is set to display dates greater than July 1, 2009.

For the Previous month you would set the fitler as follow:
Publication_Date < "7/1/2009" AND Publication_Date >= "6/1/2009" AND Expiration_Date > "#now"
The publication date is less than July 1 and greater than June 1

  • Facebook
  • Twitter
  • DZone It!
  • Digg It!
  • StumbleUpon
  • Technorati
  • Del.icio.us
  • NewsVine
  • Reddit
  • Blinklist
  • Add diigo bookmark
Post a comment!
  1. Formatting options