Would you like to flag a paragraph or an item in a bulleted list on your home page as "new" and then have the new flag disappear after a certain date? While it would be nice if we could reuse the new item functionality found in SharePoint lists and libraries, we will have to write our own. As we want to keep this as simple as possible we will add the expire date as the image's "Alternate text" attribute, which is easy to do while inserting images into a page.
In a nut shell, the basic steps for your users are:
- Edit the page or the web part
- Insert the NewFlag.jpg image (you will need to tell them the location or the URL)
- Add the expire date as MM/DD/YYYY as the "Alternate Text"
Step 1 – get an image
You can't just use the SharePoint New icon as it is stored as a sprite and not a simple image. We could use a SPAN tag, an IMG tag and a CSS class, but that's too much HTML for our site owners to add each time they want to flag something as new. So we need to find or create an image… you can draw your own in Windows Paint or you could capture the image from a SharePoint page.
Capture the image:
- Add a new item to a list or library (so we can see the New icon)
- Capture the current screen (press PrtSc on your keyboard or use a screen capture tool)
- Open Windows Paint and paste the screen capture
- Use the Select tool and select just the New icon
(for 2013) (for 2010)
- In the Paint Home ribbon click Crop and then save the file as NewFlag.jpg
- Upload this file to a SharePoint library such as Site Assets, or if you have access to the server, upload the file to c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\Template\Images (use 12 for 2007, 14 for 2010 and 15 for 2013)
- Open your site in SharePoint Designer (2007 for SP 2007, 2010 for SP 2010, etc.)
- Find and edit your master page (default.master for 2007, v4.master for 2010 and seattle.master for 2013 – note that the your master may be different!)
- Scroll to the end of the master page and find the </body> tag
- Save your master page
Step 3 – test it
- Go to the home page of a test site and edit the page
- for 2010 and 2013 home pages: Site Actions, Edit Page
- for 2007 basic pages: Site Actions, Edit Page
- for all web part pages: add a Content Editor Web Part and get it in text edit mode
- Insert the NewFlag.jpg image from wherever you uploaded it next to the new text
- Set the Alt text to the expire date (i.e. 12/24/2013)
- Insert the NewFlag.jpg image and add the expire date as the Alternative Text:
- For testing, add one image with past date and one with a future date.
For 2007 and 2010