This page last changed on Feb 23, 2012 by jed.wheeler@involver.com.

Overview

Provides the ability to display content from an RSS/Atom/MRSS feed


Configuration

The configuration settings for the RSS Feed include the feed(s) to pull in and the selection of what the featured story will be. You can associate multiple RSS feeds with the RSS Feed block. For Featured Story, you can either select one of the existing stories or you can choose to always feature the latest one.

Your configuration screen may look different than the one below


Caching Considerations

This item is cached and will not update in real time. Currently this updates every 10 minutes, or when you update the rss_feed configuration.


Block Attributes

name type required description
name string false Unique name to identify the specific feature instance that you are using in your template code. This is useful if you have multiple instances of the same feature on the same page. Defaults to 'default'

Context Variable Attributes

name type description
rss_feed.feed_items
Array of feed_item elements. Returns a collection of rss feed_items you can use to display on the page.
rss_feed.url string URL for the RSS feed source
rss_feed.total_feed_items
int Count of total feed items
rss_feed.max_stories_to_show
int Upper limit to the number of rss feed items to return
ss_feed.featured_rss_story_item
feed_item Returns the featured item for this rss_feed, as specified in the settings
rss_feed.sources
Array of rss_source elements Returns a collection of rss sources.

Examples

Simple Example

(Renders default HTML template.)

{% rss_feed %}{% endrss_feed %}

Complex Example

{% rss_feed name:"ab_rss" %}
     <ul>
          {% for blog_post in rss_feed.feed_items limit: 2 %}
              <li>
                  <h3>{{ blog_post.title | truncate: 60 }}</h3>
                  <p>{{ blog_post.formatted_published_at }}</p>

                  <div>
                     {{ blog_post.summary_text_body | strip_html | truncate: 180 }}

                      <p><a href="{{ blog_post.origin_url }}" target="_top">read more</a></p>
                  </div>
              </li>
          {% endfor %}
     </ul>

     <p><a href="{{ rss_feed.url }}" target="_top">see all</a></p>
{% endrss_feed %}

Complex Example with One Line Links

{% rss_feed name:"my_blog" %}
     <ul>
          {% for blog_post in rss_feed.feed_items offset: 2 limit: 12 %}
               <li>
                  <a href="{{ blog_post.origin_url }}" target="_top">{{ blog_post.title | truncate: 25 }} &gt;</a>
               </li>
          {% endfor %}
     </ul>
{% endrss_feed %}

Complex Example with Optional Image

{% rss_feed %}
     {% for blog_post in rss_feed.feed_items limit: 2 %}
          <div class="blog-post">
               <!-- optional image -->
               {% if blog_post.default_image %}
                    <p>
                    <img src="{{ blog_post.default_image.cached_url }}" alt=""></p>
               {% endif %}

               <h3>{{ blog_post.title }}</h3>

               <p>{{ blog_post.formatted_published_at }}</p>

               <div>
                   {{ blog_post.summary_text_body | sanitize_html: 'strict' }}
                   <p><a href="{{ blog_post.origin_url }}" target="_top">Read More</a></p>
               </div>
           </div>
    {% endfor %}
{% endrss_feed %}

Complex example with different formatting for the first post in the Feed

<div >
{% rss_feed %}
  {% for featuredstory in rss_feed.feed_items limit:1  %}

  <div id="featuredStory">
    <a href="{{ featuredstory.origin_url }}"><h2>{{ featuredstory.title }}</h2></a>
    {{ featuredstory.summary_text_body | truncatewords: 200 }}
  </div><!-- end #featuredStory -->

  {% endfor %}

  {% for recentstories in rss_feed.feed_items limit: 5 offset:1 %}

  <div id="recentstories">
    <h3><a href="{{ recentstories.origin_url }}">{{ recentstories.title }}</a></h3>
    {{ story_id }}
  </div><!-- end #recentstories -->

  {% endfor %}

  {% endrss_feed %}
</div>

By using a pair of for loops we are able to isolate the first post, format it however we like, and then set up a second for loop that starts with the second post and can be formatted differently, in this case by only listing titles.

Special Usage Case: Q & A List with Pagination

NOTES:

  • JavaScript is needed for toggle functionality to hide/show answer text.
  • You can set up a Wordpress blog to pull in RSS content from. Use the title of blog posts as the question and the post body as the answer.
<script>
$(document).ready(function() {
    $('.toggle-content').hide();

    $('.toggle-control').live('click', function() {
      var control = $(this);
      var parent = control.parents('.toggle-unit');

      parent.toggleClass('expanded');
      parent.find('.toggle-content').slideToggle();
    });
});
</script>

{% rss_feed name:"qa" %}
   {% paginate rss_feed.feed_items per_page: 6 %}
      <ul class="data-list">
         {% for blog_post in feed_items %}
            <li>
               <h3 class="question">{{ blog_post.title | truncate: 60 }}</h3>

               <div class="toggle-unit">
                  <div class="toggle-control">
                     <a href="{{ blog_post.origin_url }}" onclick="toggleContent(this);">Get answer</a>
                  </div><!-- /.toggle-control -->

                  <div class="toggle-content">
                     <p>
                        <strong>Answer:</strong>

                        <span class="answer">
                           {{ blog_post.summary_text_body | strip_html | truncate: 180 }}
                        </span>
                     </p>
                  </div><!-- /.toggle-content -->
               </div><!-- /.toggle-unit -->
            </li>
         {% endfor %}
      </ul>

      {{ pagination_links }}
   {% endpaginate %}
{% endrss_feed %}


FAQ

This feature block currently has no FAQ questions.


Related Topics

For additional information on some related components, please see the following.


rss_feed_settings.jpeg (image/jpeg)
rss_test1.jpeg (image/jpeg)
rss_test2.jpeg (image/jpeg)
rss1.jpg (image/jpeg)
Document generated by Confluence on Feb 12, 2013 09:09