Results 1 to 5 of 5

Thread: Author in gAjax RSS Feeds Displayer?

  1. #1
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Author in gAjax RSS Feeds Displayer?

    1) Script Title:
    gAjax RSS Feeds Displayer
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...sdisplayer.htm
    3) Describe problem:

    Hey everyone!

    I have recently used gAjax RSS Feeds Displayer from Dynamic Drive (using the third example). Everything works perfectly, it successfully grabbed my RSS feeds.

    Right now, I would like to put in an author to be display inside so people will know who is the one that posted the feeds but I just can't seem to get it at all.

    Please help!

    Extra note: The RSS feeds is from a forum.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You cannot get the author from the feed item unless it has one. I made up a demo with a modified gfeedfetcher.js that looks for:

    item author
    item copyright
    feed author
    feed copyright

    in that order, returning:

    unavailable

    if none of those are found.

    Of the three example feeds on the demo page only a few items in the second feed (the socialfeed) returned an author. In those three cases it was the item author.

    That said, you can try the modified script:

    gfeedfetcher.js

    It allows you to put in the on page code, for example:

    Code:
    <script type="text/javascript">
    
    var socialfeed=new gfeedfetcher("example2", "example2class", "_new")
    socialfeed.addFeed("Slashdot", "http://rss.slashdot.org/Slashdot/slashdot") //Specify "label" plus URL to RSS feed
    socialfeed.addFeed("Digg", "http://digg.com/rss/index.xml") //Specify "label" plus URL to RSS feed
    socialfeed.displayoptions("label datetime snippet author") //show the specified additional fields
    socialfeed.setentrycontainer("div") //Display each entry as a DIV
    socialfeed.filterfeed(6, "label") //Show 6 entries, sort by label
    socialfeed.init() //Always call this last
    
    </script>
    And it will try to find the author as described above. It will add this HTML at the end of the item's HTML:

    HTML Code:
    <br/><span class="authorfield">Author: something, perhaps unavailable</span>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ShieldofChaos (01-27-2012)

  4. #3
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Thanks a bunch, trying it now. Will edit the post after trying.

    Reason for this is because when I use Feed2JS and Feedburner, both of them returned the Author name who created the feeds. However I do not like both of them (weird huh haha!).

  5. #4
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Oh my gosh! The author has displayed itself! Thanks! But can I be a bit more greedy and ask for a little more request?

    Right now the feeds are displaying as this,

    Code:
    10th test haha Friday, January 27, 2012 6:45:16 PM
    hi
    Author: Admin
    No modification is done to the js at all. However, since I am only good at HTML, I can't do this part on my own.

    What I would like is for the feeds to display in this manner,

    Code:
    10th test haha 
    Friday, January 27, 2012 6:45:16 PM by Admin
    hi
    How will it be possible? Do we have to go to the js to accomplish this?

    ======

    Edit: Alright, after looking through the JS and doing many trials and errors, I finally get it. To get the output I want, I simply just look at the RSSOUTPUT line!

    This is my final code that fulfill the criteria of what I want,

    Code:
    gfeedfetcher.prototype._displayresult=function(feeds){
    	var rssoutput=(this.itemcontainer=="<li>")? "<ul>\n" : ""
    	gfeedfetcher._sortarray(feeds, this.sortstring)
    	for (var i=0; i<feeds.length; i++){
    		var itemtitle="<a href=\"" + feeds[i].link + "\" target=\"" + this.linktarget + "\" class=\"titlefield\">" + feeds[i].title + "</a>" + "<br />"
    		var itemlabel=/label/i.test(this.showoptions)? '<span class="labelfield">['+this.feeds[i].ddlabel+']</span>' : " "
    		var itemdate=gfeedfetcher._formatdate(feeds[i].publishedDate, this.showoptions)
    		var itemdescription=/description/i.test(this.showoptions)? "<br />"+feeds[i].content : /snippet/i.test(this.showoptions)? "<br />"+feeds[i].contentSnippet  : ""
    		var itemauthor = /author/i.test(this.showoptions)? "<span class='authorfield'> by "+(feeds[i].author || feeds[i].copyright || feeds.author || feeds.copyright || 'unavailable')+ "</span>": '';
    		rssoutput+=this.itemcontainer + itemtitle + " " + itemlabel + " " + itemdate + "" + itemauthor + "\n" + itemdescription + this.itemcontainer.replace("<", "</") + "\n\n"
    	}
    	rssoutput+=(this.itemcontainer=="<li>")? "</ul>" : ""
    	this.feedcontainer.innerHTML=rssoutput
    }
    It will be good if you inspect those in red and see if there are any problems with it. I tested it and it worked perfectly.

    Additionally, I have a suggestion is to put this "Author" id somewhere inside the gAjax RSS Feeds Displayer page since I believe there are people out there like me who would love to display the author of the RSS feeds.

    Thanks alot!
    Last edited by ShieldofChaos; 01-27-2012 at 05:28 PM. Reason: I solved it myself! :)

  6. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Looks good, and since it works - Great!
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ShieldofChaos (01-27-2012)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •