altica
Posts: 31
Joined: Thu Mar 19, 2009 12:07 am

Postby altica » Fri Jul 15, 2011 9:20 am

I have created a Flash application to display RSS feeds and I need to include the total number of items in the feed.

Does a feed items count variable exist?

Is it possible to create a template to create a file which includes the items count which I can pass on to the Flash application?
Graham

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Fri Jul 15, 2011 11:19 am

altica wrote:Does a feed items count variable exist?

Is it possible to create a template to create a file which includes the items count which I can pass on to the Flash application?

Tricky... Internally, Awasu tracks feed items for each channel as a continuous stream over time and doesn't really care about the composition of any particular feed XML file received. On each channel update, it just looks for any new feed items and adds them to the stream.

You might be able to do it by using the {%FEED-ITEM-COUNT-INFO%} template parameter. This inserts a "Showing ... of ... items" message when a channel is not showing all the items it would normally. To understand what I just said :-), open a channel that has a mix of newly-received and old items, open the View menu, then Show feed items, then New only. The page will switch to showing new items only and in the top-right corner, you shold see the message. You could parse this and then pass the information in to your Flash app...?

altica
Posts: 31
Joined: Thu Mar 19, 2009 12:07 am

Postby altica » Fri Jul 15, 2011 12:13 pm

Thanks - will try that. I only want to display new feeds so could parse the field in PHP
Graham

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Tue Jul 19, 2011 7:22 am

altica wrote:...a Flash application...

Cool any chance we could see a copy on Awasu's wiki?

You can also use JavaScript/jQuery to determine feed item counts. There's a couple of different ways to do this depending upon if the feed items are exported as 1) HTML DOM elements or 2) as JSON objects.

Here's as HTML DOM elements approach using a copy of Awasu's Rusty.template:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    {%INCLUDE% includes/StandardHead.include}
    <style>
        {%INCLUDE% includes/common.css}
        {%INCLUDE% Rusty.css}
        {%INCLUDE% Rusty.user.css isOptional}
    </style>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

    <script type="text/javascript">
    $(document).ready(function()
    {
      var feedItems = $(".item");
      var newFeedItems = feedItems.find("img[src$='/newFeedItem.gif']");
      var unreadFeedItems = feedItems.find("img[src$='/unreadFeedItem.gif']");
      var readFeedItems = feedItems.find("img[src$='/readFeedItem.gif']");

      alert("All items: " + feedItems.length);
      alert("New items: " + newFeedItems.length);
      alert("Unread items: " + unreadFeedItems.length);
      alert("Read items: " + readFeedItems.length);
    });
    </script>
</head>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<body>
    {%INCLUDE% includes/StandardBanner.include}
    {%INCLUDE% includes/StandardContent.include}
</body>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

</html>

Note the "unread" count should probably be the total of the "new" count and the "unread" count but you get the idea.

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Tue Jul 19, 2011 9:59 am

kevotheclone wrote:

Code: Select all

      var newFeedItems = feedItems.find("img[src$='/newFeedItem.gif']");
      var unreadFeedItems = feedItems.find("img[src$='/unreadFeedItem.gif']");
      var readFeedItems = feedItems.find("img[src$='/readFeedItem.gif']");

That's both ingenious and somehow hysterically funny :hysterical:

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Wed Jul 20, 2011 12:49 am

The same code will work in Channel Summary Templates too, however since Channel Summary Templates have the ''{%ITEM-STATE%}'' parameter, the example below would also work and would be a little more legible to a jQuery programmer as well as execute a slightly faster as jQuery simply has to find elements with a specific class name vs. a substring of an attribute value. But unless you have a huge number of feed items in a Channel Summary Template the speed difference would be negligible.

Code: Select all

var newFeedItems = feedItems.find(".itemTitleState-new");
var unreadFeedItems = feedItems.find(".itemTitleState-unread");
var readFeedItems = feedItems.find(".itemTitleState-read");


Return to “Awasu - General Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests