0

Customize RSS Feed Background Color



Hi, I have two RSS news feeds in my project. I want to manipulate them each a little differently. Here is an excerpt from my autorun.brs file: Sub UpdateRSSStrings(zone as Object, playlistItem as Object) rssStringCount = zone.widget.GetStringCount() zone.widget.PopStrings(rssStringCount) article = playlistItem.rssParser.GetNextArticle() while type(article) = "roRssArticle" artdesc = "" if article.GetDescription() = "***" then zone.widget.SetBackgroundColor(&haaff0000) endif if article.GetDescription() <> "" then artdesc = ": " + article.GetDescription() + "..." endif zone.widget.PushString(article.GetTitle() + artdesc) article = playlistItem.rssParser.GetNextArticle() endwhile End Sub My first "if" statement is successfully turning the background of the zone to red if the description of the news article equals "***" which is what I want. However, I don't know how to return the background color of the zone to its normal color if the next news article's description does not equal "***". I could simply use zone.widget.SetBackgroundColor to explicitly put it back to the non-urgent color, but since this function is called for both of my RSS ticker zones I would wind up changing the background color on both zones which I don't want to do. So what I'm looking for is either a command to set the background color back to "normal" for that zone or a way to identify which zone I'm working on at the moment. Any help would be appreciated. Michael Keen Southern Vermont College

10 comments

  • 0
    Avatar
    RokuLyndon


    Depending on the brightauthor version you have, you might already have a zonename variable you can reference. Each zone you have has a name, you can change then  name under the edit, layout tab..


    In the new zone function, you can add this line before th ereturn zoneBS at the end to save the zone name under myzoneName$


       zoneBS.myzoneName$=zoneXML.name.GetText()

       return zoneBS
       
    End Function



    THen, when you want to reference the name in your code, you can add an if statement...

    If ucase(zone.myzonename$) = "RSS-CUSTOM2" then

    endif

  • 0
    Avatar
    Mkeen


    Hi Lyndon,

    Thanks for your advice.  I actually had it working, but then I decided to upgrade the firmware to 3.8.19 and BrightAuthor to 2.4.0.17 which is apparently quite different.  Can I ask you to provide code on how to get the zonename variable on this newer platform?

    Much appreciated.

    EDIT: It also seems like the strategy for changing the background color, zone.widget.SetBackgroundColor(&haaff0000), is now also obsolete.  Would you kindly provide the updated code for setting the background color of a zone?  Thanks again.

    Michael Keen
    Southern Vermont College
  • 0
    Avatar
    Mkeen


    bump.
  • 0
    Avatar
    RokuLyndon


    There's already a name variable in the newer brightauthor autorun script. So, we don't have to add anything to newzone.

    I believe you want to find this function:

    Function STRSSLoadingEventHandler(event As Object, stateData As Object) As Object


    and, this bit of code:

    m.stateMachine.rssItem.articles.Clear()

    article = m.stateMachine.rssItem.rssParser.GetNextArticle()
    while type(article) = "roRssArticle"
    description = article.GetDescription()
    if m.stateMachine.rssItem.isTwitterFeed and m.bsp.stripTwitterUserNames and m.stateMachine.rssItem.twitterUserName$ <> "" then
    description = Mid(description, len(m.stateMachine.rssItem.twitterUserName$))
    endif
    m.stateMachine.rssItem.articles.Push(description)
    article = m.stateMachine.rssItem.rssParser.GetNextArticle()

    endwhile



    The statemachine referenced here is the zone. So, to find the name of the zone, you would check:

    m.statemachine.name$
  • 0
    Avatar
    Mkeen


    Lyndon,
    Thanks for this.  Can I also ask you to respond to my other question about how to change the background color of a zone in the newer Brightauthor script?

    Appreciate it.
  • 0
    Avatar
    RokuLyndon


    of a text zone? Text zones and live text fields have background color, but not image zones, for example.
  • 0
    Avatar
    Mkeen


    of a text zone? Text zones and live text fields have background color, but not image zones, for example.


    Yes, my goal is ultimately to automatically change the background color of an RSS text feed zone for urgent messages (which have three asterisks in the description) and then change it back to the default zone background color on the next non-urgent news item in the feed.
  • 0
    Avatar
    Mkeen


    bump
  • 0
    Avatar
    Mkeen

    bump

  • 0
    Avatar
    Mkeen

    bump

Please sign in to leave a comment.