Add An Announcements List To An Office 365 Sharepoint Public Site With A Date Range Filter

news-page2A Sharepoint Announcements list can be used to show news items, upcoming events, product introductions or any manner of short update-type items. For some reason, Msft decided not to include this type of list in the public site, and made it rather difficult to add it. Only certain types of list can be added as apps. Even if you import an announcement list template from a team site, Msft prevents it from showing up as an app you can add.Not to worry – since it’s actually a pretty simple list to create, I’m going to show you how to do that – and go one better by enhancing the basic list by adding filters so the list ONLY shows items within a specified date range. You can see a live example of the end result here ┬╗Download
If you want to skip all the fun of creating your own list (!), you can download a convenient list template here ┬╗

Create The List

Click “Add An App” and create a new custom list, naming it “News” or whatever you want.
Open the list and add list fields by clicking “create column”

create-column

Add a multi line rich text field for your announcement’s content, and 2 date fields – one for “Start date” and one for “Expiry date”.
It will look like this when you open the list’s settings:

fields

Create A Date Filtered View
The default announcements list includes an expiry date field – your custom version can go one better by adding a start date. There are many reasons you may want an announcement to become visible on your site at a specific time – if you’re running a promotion for instance. You may also want announcements to automatically drop off the public view, say after an event is over. To do that, you’ll need to create a new view of the list filtered to only display items between the start and expiry dates you set in the list.
Go to the list settings, click “Create view” and select “All items” as the starting point.

Name the view and make sure only “title” and “body” are checked
Scroll down to the filter section, and add filters as shown in the image:

news-filters

The logic of the filters may seem a little odd – I’m still not sure I understand why it works – but it does. What it says in simple terms is show only items between the start date and expiry date. In more detail, it’s saying:
Show items IF:
Expiry date is equal to nothing = when the expiry date is empty (ie there is no expiry date)
OR
Expiry date is greater than or equal to [Today] = when the expiry date is today or after today
PLUS
Start date is less than or equal to [Today = ]the start date is today or after today.
Any item that fails to meet ALL those conditions will not be shown.

View Style
To give the announcements a vertical rather than horizontal presentation, you can change the style of the view.
Scroll down the list view settings page and open the “style” option
For a vertical orientation, select the “newsletter no lines” style.
Don’t forget whenever you change the view you have to go back and reselect it in the web part properties on the page!

Add To A Page

Now the list is built, you can edit a page, look for the web part with the name of your list under “Apps” and insert it where you want it to appear. You’ll just need to switch over to your custom view as follows:
Click the web part and in the ribbon click web part “properties”.
When the properties box opens, under “List views ┬╗ selected view” pick the new view you created from the drop down.
Click ok to save your changes and remember to publish the page.

views

Add a few items to the list, and play with the date fields to test it out. Anything with a start date of today or after today AND an expiry date of today or before today should show up on the page.

Additional Points
By default, the”title” field is linked to the item but since Msft blocks anonymous access to list items, you may want to change the type of the title field from “title-linked to item” to just “title”. You can pick a different field type in the list view settings. This wi