Introduction

From their origin, feeds were intended to be an abstraction from a template, allowing you to return lists, create printer friendly pages, and various other things, completely detached from the skin and without the overhead of the DNN page itself. In fact, a feed is called by loading /DesktopModules/XModPro/Feed.aspx, which you can see is it's own page. However, you may have noticed that when creating a feed, you use a control within the feed itself (i.e. <xmod:Feed>, <xmod:JsonFeed>). So the workhorse of a feed is in fact the feed control. That means you can inject this control directly in a template without using various feed loading methods.

Example

The following is an example of using a feed directly within a <DetailTemplate> to return roles based on a user.

<xmod:Template UsePaging="True" Ajax="True">
  <ListDataSource CommandText="SELECT [UserId], [PortalId], [Username], [FirstName], [LastName] FROM vw_Users"/>
  <DetailDataSource CommandText="SELECT [UserId], [PortalId], [Username], [FirstName], [LastName], [DisplayName], [IsSuperUser], [Email], [VanityUrl], [AffiliateId], [IsDeleted], [RefreshRoles], [LastIPAddress], [UpdatePassword], [PasswordResetToken], [PasswordResetExpiration], [Authorised], [CreatedByUserId], [CreatedOnDate], [LastModifiedByUserId], [LastModifiedOnDate] FROM vw_Users WHERE [UserId] = @UserId">
    <Parameter Name="UserId" />
  </DetailDataSource>
  
  <HeaderTemplate>
    <table class="table table-striped">
      <thead>
        <tr>
          <th>User Id</th>
          <th>Portal Id</th>
          <th>Username</th>
          <th>First Name</th>
          <th>Last Name</th>
          <th>&nbsp;</th>
        </tr>
      </thead>
      <tbody>
  </HeaderTemplate>
  
  <ItemTemplate>
        <tr>
          <td>[[UserId]]</td>
          <td>[[PortalId]]</td>
          <td>[[Username]]</td>
          <td>[[FirstName]]</td>
          <td>[[LastName]]</td>
          <td>
            <xmod:DetailLink Text="Details">
              <Parameter Name="UserId" Value='[[UserId]]' />
            </xmod:DetailLink>
          </td>
        </tr>
  </ItemTemplate>
  <FooterTemplate>
      </tbody>
    </table>
  </FooterTemplate>

  <DetailTemplate>
       
        <dl class="dl dl-horizontal">
          
          <dt>UserId</dt>
          <dd>[[UserID]]</dd>
          <dt>Username</dt>
          <dd>[[Username]]</dd>
          <dt>FirstName</dt>
          <dd>[[FirstName]]</dd>
          <dt>LastName</dt>
          <dd>[[LastName]]</dd>
          <dt>DisplayName</dt>
          <dd>[[DisplayName]]</dd>
          <dt>Email</dt>
          <dd>[[Email]]</dd>
          
        </dl>
    
        <xmod:Feed>
    
          <ListDataSource CommandText="SELECT * FROM dbo.vw_UserRoles WHERE UserId = @UserId">
            <Parameter Name="UserId" Value='[[UserID]]' DataType="Int32" />
          </ListDataSource>
          
          <HeaderTemplate>
            <h4>Roles</h4>
            <ul>
          </HeaderTemplate>
          <ItemTemplate>
            <li>[[RoleName]]</li>
          </ItemTemplate>
          <FooterTemplate>
            </ul>  
          </FooterTemplate>
          
        </xmod:Feed>
                
        <xmod:ReturnLink CssClass="btn btn-default" Text="Go Back" />  

  </DetailTemplate>
</xmod:Template>
Feeds in Templates

Awesome!

Share your progress with your friends!