Task (based on the actual request from our user): I need a widget that would display exactly one randomly selected item of my digest each time the page where it's embedded is loaded in browser.
Problem: you can create a widget comprising of just one random item using built-in tools, but due to technical limitations it will update only when digest's content is updated, which is not what we want.
For the sake of brevity, HTML code of our widget will be quite simple.
<ul id="fi-widget-1" style="display: none; margin: 0; padding: 0">
<li style="display: none; margin: 0; padding: 0">
<strong><a target="_blank" href="%URL%">%TITLE%</a></strong>
Now let's write a function that would unhide a random
<li> element (they are hidden initially, as well as the container
You can embed your script into page template, but you have a choice to incorporate it into the widget itself.
Let's do the latter approach and save our function code in the Header part of the widget, before
Now we just need to call the function. Since it's important to call it after the HTML code of the widget, it would be logical to put the call in Footer template, after
You can check the widget in action here.
To import complete widget code, please visit the same link and click CUSTOMIZE button, then click 'Edit template manually' link and copy code snippets for each part of the widget to the corresponding fields of your template.
That's a simple demonstration of how to expand your widget capabilities beyond the core functionality provided by Feed Informer. We'd like to invite our power user to share their own examples of advanced widget templates that other user may find useful. The best examples will be republished here or we can provide a link to your web page where the widget code can be found. Please make your code available under Creative Commons license so it can be used by others without restrictions.