How to create a list of 10 latest news articles
Create the channel
sitenews.Create the file format
newsitemand activate its option Mark as new on the live server (canCreateNewsItems).Create the file
news1anywhere in the folder hierarchy. Usenewsitemas the format of the file.Add code like this to the layout of the starting page:
<ul> <npsobj newslist="all" length="10"> <li> <npsobj insertvalue="anchor" name="self"> <npsobj insertvalue="var" name="title" /> </npsobj> </li> </npsobj> </ul>
How to create an RSS feed for politics news
Create the channel
politics.Create the file format
newsitemand enable its option Mark as news on the live server (canCreateNewsItems).Define a field
description. Create the file formatfeedand add thedescriptionfield to it. Do not activatecanCreateNewsItemsforfeed.Create the folder
rssfeeds.In the folder create a base layout which outputs an RSS feed (see below).
In the same folder create the file
politicsfeedusing thefeedformat and set itsdescriptionto "Company policy news". Assign to it thepoliticschannel.Set the main content of the base layout to the following:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.92//EN" "https://my.netscape.com/publish/formats/rss-0.92.dtd"> <rss version="0.92"> <channel> <description> <npsobj insertvalue="var" name="description" /> </description> <language>de</language> <title><npsobj insertvalue="var" name="title" /></title> <link>https://www.mysite.com/</link> <copyright>(c) JustRelate Group GmbH</copyright> <generator>CMS Fiona 6.7.0</generator> <ttl>60</ttl> <npsobj newslist="selected" name="channels" length="20"> <item> <title><npsobj insertvalue="var" name="title"/></title> <link>https://www.mysite.de<npsobj insertvalue="var" name="visiblePath" /></link> <description> <npsobj insertvalue="var" name="description"/> </description> </item> </npsobj> </channel> </rss>
To output the RSS feed in a different version (for example 2.0) you can modify the layout file as desired.
To generate another feed for sports news using the layout file above:
Create a channel named
sports.In the
rssfeedsfolder create the filepoliticsfeedusing thefeedformat and set the file’sdescriptionfield to "Latest sports news". As channels selectsports.Now create files based on the
newsitemformat and set theirchannelsfield tosports. The files will be added to the Sports news feed.
Sending a Newsletter
Create a folder named
newsletters.Write a base layout that generates the contents of the newsletter by reading fields from the corresponding files, for example.
Create a file format named newsletter.
In the
newslettersfolder create the filepoliticsbased on the file formatnewsletters.Into the main content of the
politicsfile enter the e-mail addresses. Only one address per line.Write a wizard that sends the
exportBlobfield ofpoliticsto each e-mail address in the main content ofpolitics.