Add news to your website
The package implements the typical news list functionality in a simple and easy way. When implemented, it lists the latest news or news teasers on a web page. Clicking a news item shows the news content ("the full story"). You can choose how many news items to display on a page and how many news lists to have. Earlier news can be accessed in their corresponding news archives.
Technical description
The package installs 2 functions:
- Composite.News.NewsTeasers: shows the latest news on a page as news teasers
- Composite.News.NewsList: shows all the news (list) or the content of a selected news item (details)
How to implement Composite.News
The package comes with a page type "News page" you can create a page with. It will add the news feature to the page automatically:
- Create a page.
- Select "News page" for its Page type.
This will add the "News" application and the "Composite.News.NewsList" and "Composite.News.NewsTeasers" functions to the page.
Note: This requires that the layout template the page is using has two placeholders with these IDs:
- 'content' ( for the Composite.News.NewsList function)
- 'aside' (for the Composite.News.NewsTeasers function)
Otherwise, consider adding the news-related functionality to pages manually as described below.
Adding the News application manually
- Right-click the page you will use to store news under.
- Click Add Application.
- In the Add Application window, select "News" in the Application drop-down list.
- Click Finish.
Adding Composite.News.NewsList manually
- Edit the page where you have added the "News" application.
- On the
Content tab, insert the
Composite.News.NewsList function (
Insert >
Function), or add the following code:
<f:function name="Composite.News.NewsList" xmlns:f="http://www.composite.net/ns/function/1.0"> <f:param name="ListOptions" value="Show date,Show teaser" /> <f:param name="ItemOptions" value="Show date,Show news story,Show share icons,Show 'Back to News' link" /> <f:param name="PageSize" value="10" /> <f:param name="DateFormat" value="dddd, MMMM dd, yyyy" /> </f:function>
- If needed, set these optional parameters:
-
List options: Additional data to show when displaying news items in a list, such as the date, teaser, description, RSS link. (By default the date and the teaser are displayed.)
-
Item options: Additional data to show when displaying a single news item, such as the date, teaser, news story, share icons, "Back to News" link. (All the options but "teaser" are displayed by default.)
- Page Size: The number of items to display on the page ("10" by default).
- Date Format: the custom C#-compliant date format (by default, it corresponds to "dddd, MMMM dd, yyyy").
-
Adding Composite.News.NewsTeasers manually
- Create or edit the page the latest news will appear on (for example, the front page of the website).
- On the
Content tab of the page for the
latest news, insert the
Composite.News.NewsTeasers function (
Insert >
Function), or add the following code:
<f:function name="Composite.News.NewsTeasers" xmlns:f="http://www.composite.net/ns/function/1.0"> <f:param name="Count" value="5" /> <f:param name="Options" value="Show date,Show teaser" /> <f:param name="DateFormat" value="dddd, MMMM dd, yyyy" /> </f:function>
- (Optionally) Set these parameters:
- Count: The number of items to display on the page ("5" by default).
- Options: Additional data to show in the news list such as the date and teaser. (By default, the date and the teaser are displayed.)
- Date Format: the custom C#-compliant date format (by default, it corresponds to "dddd, MMMM dd, yyyy").
- Count: The number of items to display on the page ("5" by default).
Note: If you have more than one news list on the website, the latest news from all the lists will be displayed here.
How to add and publish news
- Expand the "news" page and select News.
- Click Add News on the toolbar.
- On the
Settings tab, fill out these fields:
- Title: The title of the news item
- Date: The date of the news item
- Teaser: The short description of the news item
- On the Description tab, write content for the news item.
- Click Save and click Publish.
How to implement typical RSS feed functionality
To access the RSS feed of the news on the website, use the following URL:
http://<HostName>/NewsRssFeed.ashx/<culture>
where <culture> stands for the culture code (such as "en-US") used on your site. For example,
http://www.contoso.com/NewsRssFeed.ashx/en-US
To enable localization of the news:
- In the Data perspective, select the Composite.News.NewsItem page datafolder.
- Click Enable Localization on the toolbar.
- Follow the wizard.
Important Notes
- The Composite.News.NewsList function should be only added on the page where the "News" application has been added.
- Only published news items will be displayed on the page.
Requirements
Composite C1 version 3.2 or later