The Feed tag, first introduced in version 3.0, is used to define the output of feeds. A feed typically is thought of as an RSS feed, but it can be much more than that. With the Feed tag, you can produce virtually any XML-based output, a printer-friendly HTML page, a plain text page, even a comma-delimited file that can be automatically opened by Excel or a similar program.
Creating a feed is a two-step process:
It's important to note that feeds, by their nature, are typically intended to be public. No special security measures have been implemented for securing the feed. So you should be careful about what data you make available through a feed. One way you could make your feed more secure is by creating and passing a token to the feed. This token would then be checked by your data source (most likely a stored procedure) to determine its validity, returning the data only if it's valid.
<xmod:feed
Doctype="string"
ContentType="string"
ConnectionString="string"
Filename="string"
ViewRoles="role1,role2,role3">
<ListDataSource CommandText="string"
ConnectionString="string"/>
<HeaderTemplate>...</HeaderTemplate>
<ItemTemplate>...</ItemTemplate>
<AlternatingItemTemplate>...</AlternatingItemTemplate>
<SeparatorTemplate>...</SeparatorTemplate>
<FooterTemplate>...</FooterTemplate>
</xmod:feed>
ConnectionString: If you need to specify a SQL Server database other than the current DotNetNuke database, you can supply a connection string here. When specified, it serves as the default connection string for the ListDataSource and DetailDataSource. You can also use a connection string defined in the web.config file. To do so, use the ConnectionString token like so:
<xmod:feed ... ConnectionString='[[ConnectionString:connectionName]]' ...>
SELECT
command or a stored procedure. Supply the SQL command as the CommandText attribute. For stored procedures, use EXEC sprocName
. Note that Bit columns are returned as True/False - not 1/0. The data source for a feed is defined in the <ListDataSource>
tag. ListDataSource: Provides the data for the template when it is displaying in list view. It accepts <parameter> tags to pass parameters as part of the command. The "alias" attribute is optional and is used to avoid conflicts or to accept a parameter with a specific name (the "name" attribute) but use a different parameter name in the command (the "alias" attribute). If no "alias" is specified, the "name" will be used.
Examples:
#1 <ListDataSource CommandText="SELECT FirstName, LastName FROM Users" />
#2 <ListDataSource CommandText="SELECT FirstName, LastName FROM Users WHERE ZipCode = @zip"> <parameter name="zip" alias="zip" value="12345" /> </ListDataSource>
#3 <ListDataSource CommandText="EXEC GetUsers @zip"> <parameter name="zip" alias="zip" value="12345" /> </ListDataSource>
You can optionally specify a ConnectionString for this data source. If none is specified, the default connection will be used - either the connection specified by the ConnectionString property of the parent <xmod:feed>
tag or the current DotNetNuke database if the tag doesn't define a connection. As with the template tag, you can use the [[ConnectionString:connectionName]]
token to use a connection defined in the web.config file.
[[FieldName]]
"FieldName" is the name of the field or column in your data source. It must be surrounded by [[ and ]]. You can use the Field Token in many places. However, when you use it as the attribute value for an XMod Pro tag or other third party control, you must delimit the attribute value with single quotes, rather than double quotes. For example, when used in the <parameter>
tag, the attribute is written as: value='[[UserID]'
rather than: value="[[UserID]]"
. When using a Field Token with HTML tag attributes, this is not necessary.<xmod:Feed ContentType="application/vnd.ms-excel" Filename="test.csv">
<ListDataSource CommandText="SELECT [AuthorId], [FirstName], [LastName], [GenreId] FROM Authors"/>
<HeaderTemplate>Author Id,First Name,Last Name,Genre Id</HeaderTemplate>
<ItemTemplate>[[AuthorId]],[[FirstName]],[[LastName]],[[GenreId]]</ItemTemplate>
</xmod:Feed>