Involver Developer Network : rss_feed
This page last changed on Feb 23, 2012 by jed.wheeler@involver.com.
OverviewProvides the ability to display content from an RSS/Atom/MRSS feed
ConfigurationThe 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 ConsiderationsThis 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
Context Variable Attributes
ExamplesSimple 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 }} ></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 PaginationNOTES:
<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 %} FAQThis feature block currently has no FAQ questions. Related TopicsFor additional information on some related components, please see the following. ![]() ![]() ![]() ![]() |
![]() |
Document generated by Confluence on Feb 12, 2013 09:09 |