<xmod:LoadFeedLink>

The LoadFeedLink tag makes it a cinch to dynamically load XMod Pro feeds into your page. This tag requires jQuery be included in the page. The LoadFeedLink tag renders as a hyperlink at run-time and will grab the feed data when clicked.

Syntax

<xmod:LoadFeedLink
  FeedName="string"
  IDSelector="jQuery element selector"
  InfinitePaging="True|False"
  InsertMode="Replace|Append|Prepend"
  LoadingCssClass="CSS Class Name(s)"
  LoadingImageUrl="url"
  Target="jQuery element selector"
  Text="string"
  [one or more optional Field tags can be used to pass data to the feed]

<Field Name="string" Value="string" />
</xmod:LoadFeedLink>

Remarks

Back to top

Example

This example shows two LoadFeedLink tags. They retrieve different feeds but place them in the same element on the page (the DIV with id of Content). When the "Show Top Authors" is clicked, the Content DIV will display the list of Top 20 authors. If you then click the "Show Top Crime Books" the contents of the DIV tag will be replaced with the top 20 crime books. The two feeds are shown after the template example.


<!-- Main Content DIV Feed Results Will Be Placed Here -->
<div id="Content"></div>


<!-- LOAD FEED TAGS -->
<xmod:LoadFeedLink Text="Show Top Authors" FeedName="Top20Authors" Target="#Content" LoadingImageUrl="~/images/loading.gif" />
<xmod:LoadFeedLink Text="Show Top Crime Books" FeedName="Top20CrimeBooks" Target="#Content">
  <Field Name="GenreId" Value="20" />
</xmod:LoadFeedLink>
 

Example Feeds -- Top20Authors

<xmod:Feed ContentType="text/html">
  <ListDataSource CommandText="SELECT FirstName, LastName, AuthorId, SalesRank FROM Authors WHERE SalesRank <= 20" />
  <HeaderTemplate>
    <table>
      <thead>
        <tr>
          <th>Rank</th>
          <th>Author</th>
        </tr>
      </thead>
      <tbody>
  </HeaderTemplate>
  <ItemTemplate>
        <tr>
          <td>[[SalesRank]]</td>
          <td>[[FirstName]] [[LastName]]</td>
        </tr>
  </ItemTemplate>
  <FooterTemplate>
      </tbody>
    </table>
  </FooterTemplate>
</xmod:Feed>

Example Feeds -- Top20CrimeBooks

<xmod:Feed ContentType="text/html">
  <ListDataSource CommandText="SELECT Title, SalesRank FROM Books WHERE GenereId = @GenreId">
    <Parameter Name="GenreId" Value='[[Url:GenreId]]' />
  </ListDataSource>
  <HeaderTemplate>
    <table>
      <thead>
        <tr>
          <th>Rank</th>
          <th>Title</th>
        </tr>
      </thead>
      <tbody>
  </HeaderTemplate>
  <ItemTemplate>
        <tr>
          <td>[[SalesRank]]</td>
          <td>[[Title]]</td>
        </tr>
  </ItemTemplate>
  <FooterTemplate>
      </tbody>
    </table>
  </FooterTemplate>
</xmod:Feed>

 

Example - Infinite Paging

This example shows how you can setup "Infinite Paging". The idea behind infinite paging is that the user is presented with an initial list of, say, 10 results. If there are 100 total records, normally the user would page to the next set of 10 and keep paging to browse through the results. Infinite paging leverages the power of AJAX to present all those results on the same page. So, the user is presented with a button that, when clicked, will load the next set of 10 results and add them to the existing list. So, now the list contains a total of 20 results. If the button is pressed again, 10 more results will be added to the list for a total of 30 results. The two feeds are shown after the template example.

NOTE: Infinite Paging will send your feed a parameter called "LastId" that you can use to determine the next set of values to return. However, Infinite Paging needs to you to tell it where it can get the LastId. You do this by setting the IDSelector property. This should be a jQuery selector that points to the element that contains that value. XMod Pro will grab the innerText of that element and use that as the LastId. In the example below, we're storing the Author's ID in a hidden SPAN tag. Since the last-retrieved record id is going to be in the last record we display, we'll find the LastId in the list item.


<xmod:Template>
  <ListDataSource CommandText="SELECT TOP 10 AuthorId, FirstName, LastName FROM Authors" />

  <HeaderTemplate>
    <ul id="AuthorsList">
  </HeaderTemplate>

  <ItemTemplate>
      <li>[[FirstName]] [[FirstName]]<span style="display:none;">[[AuthorId]]</span></li>
  </ItemTemplate>

  <FooterTemplate>
    </ul>
<xmod:LoadFeedLink Text="Show Next 10 Authors" FeedName="Authors_Chunked" LoadingImageUrl="~/images/loading.gif" 
     Target="#AuthorsList" IDSelector="#AuthorsList li:last span" InsertMode="Append" />
  </FooterTemplate>


Example Feed -- Infinite Paging, Authors

This feed is designed to work with the template specified above. There are several important items to implement to ensure successful implementation of infinite paging.

  1. The feed must have its ContentType set to "text/html" since we're sending HTML back to the template.
  2. The ListDataSource should use the URL parameter called "LastId" to determine which record(s) to return.
  3. The ListDataSource is set to select the first 10 records that match the WHERE clause criteria. This allows you to return the next 10 records to the template. If your template was set to retrieve the next 20 records, the ListDataSource should SELECT TOP 20 ...
  4. The ListDataSource has a <Parameter> tag that grabs the URL parameter called "LastId" that is passed automatically by XMod Pro.
  5. Since we are injecting HTML into the template's page, we only need to render out the minimum HTML to add List Items to the unordered list. So, we don't have a HeaderTemplate or FooterTemplate - just an ItemTemplate matches the ItemTemplate in the <xmod:Template> tag above. This is important not only to maintain visual consistency but you must also be sure to include the <span> tag that contains the record's ID.
<xmod:Feed ContentType="text/html">
  <ListDataSource CommandText="SELECT TOP 10 FirstName, LastName, AuthorId FROM Authors WHERE AuthorId > @LastId ORDER BY AuthorId ASC">
    <Parameter Name="LastId" Value='[[Url:LastId]]' />
  </ListDataSource>
  <ItemTemplate>
        <li>[[FirstName]] [[LastName]]<span style="display:none;">[[AuthorId]]</span></li>
  </ItemTemplate>
</xmod:Feed>
 
 
Back to top