Question
When I use RSS feed in my content, sometimes the feed is blank. How do I print alternate content if the feed is blank?
Answer
If you have a template calling in an RSS feed, you may occasionally run into an issue where the Feed is missing for some reason. To account for this, set the feed to a variable, and then test if the variable is blank, as follows:
%%set [VARIABLE] = {{rssobject [NAME].[ATTRIBUTE] [ENTRY_NUMBER]}}%%
%%if [VARIABLE] == "" then print "[STRING]" else print "##$[VARIABLE]##"%%
For example:
%%set rssTitleTester = {{rssobject myfeed.title 1}}%% %%set rssContentTester = {{rssobject myfeed.content 1}}%% %%if rssTitleTester == "" then print "Alternate Title" else print "##$rssTitleTester##"%%<br /> %%if rssContentTester == "" then print "There is no new content at this time." else print "##$rssContentTester##"%%