{"id":1761,"date":"2012-06-25T15:47:46","date_gmt":"2012-06-25T14:47:46","guid":{"rendered":"http:\/\/blogs.oucs.ox.ac.uk\/adamweblearn\/?p=1761"},"modified":"2013-08-28T14:25:54","modified_gmt":"2013-08-28T13:25:54","slug":"displaying-rss-twitter-feeds-on-html-pages-in-weblearn","status":"publish","type":"post","link":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/2012\/06\/displaying-rss-twitter-feeds-on-html-pages-in-weblearn\/","title":{"rendered":"Displaying RSS (&amp; Twitter) feeds on HTML pages in WebLearn"},"content":{"rendered":"<p>WebLearn has a built-in tool, News, for displaying RSS feeds; it is even possible to display feeds from Oxford Podcasts &#8211; these will feature an in-page media player for audio and audio-visual podcast display.<\/p>\n<p>Sometimes it is desirable to insert one or more newsfeeds within a regular HTML page. This is now easy to achieve in WebLearn.<\/p>\n<p>You should create an HTML page in Resources in the usual way. You must then add special HTML code to render a feed.<\/p>\n<p>To insert this code, switch to the &#8216;Source&#8217; view within the editor; you may also find it useful to show a full screen version of the editor.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/editor-source-view1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-1763\" style=\"border: 1px solid black\" alt=\"\" src=\"http:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/editor-source-view1.png\" width=\"583\" height=\"351\" srcset=\"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/editor-source-view1.png 729w, https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/editor-source-view1-300x180.png 300w\" sizes=\"auto, (max-width: 583px) 100vw, 583px\" \/><\/a><\/p>\n<p>The following code snippet will display the latest 5 blog posts from the WebLearn blog. To do this you must know the URL of the RSS feed, in the following example it is <em>http:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/feed\/<\/em>, other examples are\u00a0<em>http:\/\/feeds.bbci.co.uk\/news\/rss.xml<\/em> (BBC news feed) and <em>http:\/\/search.twitter.com\/search.atom?q=@_markstewart<\/em> (Mark Stewart&#8217;s Twitter feed).<\/p>\n<p>An explanation of the configuration parameters will be given below.<\/p>\n<pre>&lt;!-- include jquery library --&gt;\r\n&lt;script\r\n  src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.7.1\/jquery.min.js\"\r\n  type=\"text\/javascript\"&gt;\r\n&lt;\/script&gt;  \r\n\r\n&lt;!-- include zrssfeed functions stored in WebLearn --&gt;\r\n&lt;script\r\n  src=\"https:\/\/weblearn.ox.ac.uk\/access\/content\/public\/misc\/js\/jquery.zrssfeed.min.js\"\r\n  type=\"text\/javascript\"&gt;\r\n&lt;\/script&gt;       \t\r\n\r\n&lt;!-- output the rss feed within a 'DIV' with id wl-blog\r\n     (you may use any name) --&gt;\r\n&lt;script type=\"<a>text\/javascript<\/a>\"&gt;\r\n$(document).ready(function () {\r\n\r\n  $('#wl-blog').rssfeed('http:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/feed\/', {\r\n    limit: 5,\r\n    titletag: 'h3',\r\n  \u00a0 ssl: true,\r\n    linktarget: _blank,\r\n    media: true,\r\n    snippet: false\r\n  });\r\n});\r\n&lt;\/script&gt;\r\n\r\n&lt;!-- here is the DIV where the feed will appear --&gt;\r\n&lt;div id=\"<a>wl-blog<\/a>\"&gt;&amp;nbsp;&lt;\/div&gt;<\/pre>\n<p>This will render as:<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/blog-display.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-1767\" style=\"border: 1px solid black\" alt=\"\" src=\"http:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/blog-display.png\" width=\"493\" height=\"546\" srcset=\"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/blog-display.png 616w, https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/blog-display-270x300.png 270w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><\/a><\/p>\n<p>It should be pointed out that the above JavaScript used Google AJAX feeds and as such the newsfeeds are cached by Google. It would appear that there could be a couple of hours delay between updating the feed and the changes becoming visible.<\/p>\n<p>The <em>&#8216;rssfeed<\/em>&#8216; function has a number of parameters. The following table is taken from <a href=\"http:\/\/www.zazar.net\/developers\/jquery\/zrssfeed\/\">http:\/\/www.zazar.net\/developers\/jquery\/zrssfeed\/<\/a>.<\/p>\n<table border=\"0\">\n<tbody>\n<tr>\n<th>Parameter<\/th>\n<th>Default<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>limit<\/td>\n<td>10<\/td>\n<td>The number of feeds to return.<\/td>\n<\/tr>\n<tr>\n<td>header<\/td>\n<td>true<\/td>\n<td>If true, includes the header section containing the feed name and link.<\/td>\n<\/tr>\n<tr>\n<td>titletag<\/td>\n<td>&#8216;h4&#8217;<\/td>\n<td>Specifies the HTML tag for the feed title.<\/td>\n<\/tr>\n<tr>\n<td>date<\/td>\n<td>true<\/td>\n<td>If true includes the feed date section.<\/td>\n<\/tr>\n<tr>\n<td>content<\/td>\n<td>true<\/td>\n<td>If true includes the feed description.<\/td>\n<\/tr>\n<tr>\n<td>snippet<\/td>\n<td>true<\/td>\n<td>If true the snippet short description is shown available when available.<\/td>\n<\/tr>\n<tr>\n<td>media<\/td>\n<td>true<\/td>\n<td>If true displays media items when available.<\/td>\n<\/tr>\n<tr>\n<td>showerror<\/td>\n<td>true<\/td>\n<td>If true and an error is returned from the Google Feeds API, the error message is shown.<\/td>\n<\/tr>\n<tr>\n<td>errormsg<\/td>\n<td>&#8211;<\/td>\n<td>Replaces the default friendly message when an error occurs.<\/td>\n<\/tr>\n<tr>\n<td>key<\/td>\n<td>null<\/td>\n<td>Optionally use a Google API key.<\/td>\n<\/tr>\n<tr>\n<td>ssl<\/td>\n<td>false<\/td>\n<td>Support for SSL. Set to True when using secure pages.<\/td>\n<\/tr>\n<tr>\n<td>linktarget<\/td>\n<td>&#8216;_self&#8217;<\/td>\n<td>Specifies the target for all feed links (&#8216;_blank&#8217;, &#8216;_self&#8217;, &#8216;_top&#8217;, framename).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Note: In order to prevent &#8216;mixed content warnings&#8217; one should always set the <em>ssl<\/em> parameter to <em>true<\/em>.<\/p>\n<p>Another example showing the first 10 titles in an &lt;li&gt; list format:<\/p>\n<pre>&lt;!-- output the rss feed within a 'DIV' with id wl-blog\r\n     (you may use any name) --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n\r\n$(document).ready(function () {\r\n\r\n  $('#wl-blog').rssfeed('http:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/feed\/', {\r\n    limit: 10,\r\n    titletag: 'p',\r\n    date: false,\r\n    ssl: true,\r\n    content: false,\r\n    header: false,\r\n    linktarget: '_self',\r\n    media: true,\r\n    snippet: false\r\n  });\r\n});\r\n&lt;\/script&gt;<\/pre>\n<p>This will look like<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/blog-display-minimal.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-1771\" style=\"border: 1px solid black\" alt=\"\" src=\"http:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/blog-display-minimal.png\" width=\"350\" height=\"265\" srcset=\"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/blog-display-minimal.png 438w, https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/files\/2012\/06\/blog-display-minimal-300x226.png 300w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/a><\/p>\n<p>The world is now your oyster<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WebLearn has a built-in tool, News, for displaying RSS feeds; it is even possible to display feeds from Oxford Podcasts &#8211; these will feature an in-page media player for audio and audio-visual podcast display. Sometimes it is desirable to insert &hellip; <a href=\"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/2012\/06\/displaying-rss-twitter-feeds-on-html-pages-in-weblearn\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[295,105],"tags":[206,389],"class_list":["post-1761","post","type-post","status-publish","format-standard","hentry","category-web","category-weblearn","tag-content","tag-news-tool"],"_links":{"self":[{"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/posts\/1761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/comments?post=1761"}],"version-history":[{"count":16,"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/posts\/1761\/revisions"}],"predecessor-version":[{"id":2852,"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/posts\/1761\/revisions\/2852"}],"wp:attachment":[{"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/media?parent=1761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/categories?post=1761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs-new.it.ox.ac.uk\/adamweblearn\/wp-json\/wp\/v2\/tags?post=1761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}