Knowledge Base > Syndication Services > Editor's Desk and Widgets
Search the Knowledge Base
 
Date Modified
Tuesday, February 19, 2008
Widget How to: Associate an image with a feed (that's not part of the RSS)

This Knowledge Base article pertains to a premium Editor's Desk account, which allows users far more customization options beyond a basic account. The premium level account includes integration of HTML, CSS, and JavaScript to refine your widgets. If you'd like more information about how you can take advantage of our robust version of Editor's Desk, please contact craigl@newsgator.com.

 

Problem:
You are looking to associate a logo or image with a feed or a piece of content, this isn't included in the RSS feed.

 

Solution:
Create an 'if statement' in javascript that will write out the appropriate image when the conditions of the 'if statement' are matched.

 

How to:
In the JavaScript pane of Editor's Desk (located within the Design tab of a widget), we'll create the following function, using the FeedName as the element in the feed to key off of...

function getImageLink(FeedName)
{
                var result = '';
                switch (FeedName)
                {
                                case blog1name: result='<a href="blog1url"><img src="image1url"> '; break;
                                case blog2name: result='<a href="blog2url"><img src="image2url"> '; break;
                                default: result=''
                }
                return result;
}
Then, within the HTML section, you can call the javascript function you wrote with the following code:
${getImageLink(Post.FeedName)}

What this will do is pass the FeedName token (the name of the feed) into the JavaScript function getImageLink, and the javascript function will spit out the appropriate image (html) for that Feed.

 

Caveat:
Some feeds may have characters in their name (like apostrophes) that may require slightly more robust code to work around. But this solution should be sufficient for the majority of feeds.   



Knowledge Base Software - myKB.com