Results 1 to 6 of 6

Thread: gAjax RSS Feeds Displayer - display more feed characters

  1. #1
    Join Date
    Jul 2010
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default gAjax RSS Feeds Displayer - display more feed characters

    1) Script Title: gAjax RSS Feeds Displayer v2.0 (hosted)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...sdisplayer.htm

    Question:

    What do I tweak (and where) to make a feed display more characters?

    Thank you!
    Last edited by jscheuer1; 07-23-2014 at 06:42 PM. Reason: threads/posts merged

  2. #2
    Join Date
    Aug 2004
    Posts
    9,893
    Thanks
    3
    Thanked 966 Times in 954 Posts
    Blog Entries
    15

    Default

    For which field (ie: title or description) do you wish to display more characters? For the description field, you can show everything that's made available to you inside the RSS file by passing in the keyword "description" inside the displayoptions() function when initializing the script:
    Code:
    myrssvar.displayoptions("datetime label description")
    For the title field, the number of characters shown is not controlled by the script and can't be altered.
    DD Admin

  3. #3
    Join Date
    Jul 2010
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I have this, for instance:

    The Future Is Bright! (Junior Programs)
    By Andy Keller – CXC Development Coach Wow! This summer has been flying by with all the camps and programs we have had going on ...

    I'd like to extend the description part by one more sentence. I certainly don't need everything.. I remember changing a number (for the description field character count) somewhere in the js script, but I can't recall where..

    Here is my script:

    Code:
    <script type="text/javascript">
    
    var socialfeed=new gfeedfetcher("example5", "example5class", "_new")
    socialfeed.addFeed("(Sport Science)", "http://cxcacademy.wordpress.com/category/sport-science/feed/atom") 
    socialfeed.displayoptions("label snippet") //show the specified additional fields
    socialfeed.setentrycontainer("div") //Display each entry as a DIV
    socialfeed.filterfeed(2, "label") //Show 6 entries, sort by label
    socialfeed.onfeedload = function(){
    	var $ = jQuery, $firsttitle = $(this.feedcontainer).find('.titlefield').eq(0), mw = $(this.feedcontainer).children().innerWidth() - 5, $p, $r;
    	$.each(this.feeds, function(i, feed){
    		$p = $(feed.content).find('img').eq(0).css({maxWidth: mw, height: 'auto'});
    		$r = $p.parent('a').length? $p.parent('a') : $p;
    		if($r.length){return false;}
    	});
    	if($r.length){$firsttitle.before($('<div></div>').append($r));}
    };
    socialfeed.init() //Always call this last
    
    </script>

    I did find a thread back from 2010.. that says:

    To change the 200 character limit to something else, inside the .js file, you'd change 200 below to another number:

    Code:
    itemdescription=itemdescription.replace(re, "").substring(0, 200)
    		if (itemdescription.length==200)
    			itemdescription+='...'
    but I don't have such code lines in my .js file anymore.. I think the .js file was replaced with a new one at some point.

    Thank you!
    Last edited by cxcskiing; 07-23-2014 at 03:35 PM.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,982
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    Sounds like you're only displaying the snippet part instead of the description. Change that (using the second example from the demo page):

    Code:
    var socialfeed=new gfeedfetcher("someid", "someclass", "_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") //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
    to the description itself:

    Code:
    var socialfeed=new gfeedfetcher("someid", "someclass", "_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 description") //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
    - John
    ________________________

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

  5. #5
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,799
    Thanks
    2
    Thanked 420 Times in 414 Posts

    Default

    untested but changes in red

    Code:
    gfeedfetcher.prototype._displayresult=function(feeds){
    	var rssoutput=(this.containertag[0]=="li")? "<ul>\n" : ""
    	gfeedfetcher._sortarray(feeds, this.sortstring)
    	var itemurl=[], itemtitle=[], itemlabel=[], itemdate=[], itemdescription=[]
    	for (var i=0; i<feeds.length; i++){
    		itemurl.push(feeds[i].link)
    		itemtitle.push('<span class="titlefield"><a href="' + feeds[i].link + '" target="' + this.linktarget + '">' + feeds[i].title + '</a></span>\n')
    		itemlabel.push(/label/i.test(this.showoptions)? '<span class="labelfield">'+this.feeds[i].ddlabel+'</span>\n' : "")
    		itemdate.push(gfeedfetcher._formatdate(feeds[i].publishedDate, this.showoptions))
    		var itemdescriptionsingle=/description/i.test(this.showoptions)? feeds[i].content : /snippet/i.test(this.showoptions)? feeds[i].contentSnippet  : ""
    		itemdescriptionsingle=(itemdescriptionsingle!="")? '<span class="descriptionfield">' + itemdescriptionsingle + '</span>\n' : ""
    		itemdescription.push(itemdescriptionsingle)
    	}
     	// create temp object to store references to rss components, for access dynamically:
    	var holder={urlfield: itemurl, titlefield: itemtitle, labelfield: itemlabel, datefield: itemdate, descriptionfield: itemdescription}
    	var regexprules=this.regexprules
    	for (var i=(this.regexprules && this.regexprules.length>0? this.regexprules.length-1 : -1); i>=0; i--){ // loop thru regexprules array
    		if (regexprules[i][2]=="titlefield" || regexprules[i][2]=="labelfield" || regexprules[i][2]=="datefield" || regexprules[i][2]=="descriptionfield"){
    			var targetarray=holder[regexprules[i][2]] // reference array containing said field type (ie: itemdescription if regexprules[i][2]=="descriptionfield")
    			targetarray=targetarray.join('***delimiter***') // combine array elements before doing search and replace
    				.replace(regexprules[i][0], regexprules[i][1])
    				.split('***delimiter***') // revert back to array
    			holder[regexprules[i][2]]=targetarray
    			regexprules.splice(i,1) // remove this rule from regexprules
    		}
    	}
    	for (var t,i=0; i<feeds.length; i++){ // loop thru feeds, molding each feed entry based on template
    		rssoutput+= this.containertag[1] + this.outputtemplate.replace(/({title})|({url})|({label})|({date})|({description})/ig, function(m){
    			if (m == "{title}")
    				return holder.titlefield[i]
    			else if (m == "{url}")
    				return holder.urlfield[i]
    			else if (m == "{label}")
    				return holder.labelfield[i]
    			else if (m == "{date}")
    				return holder.datefield[i]
    			else if (m == "{description}"){
                    t=holder.descriptionfield[i].slice(0,200);
                    t+=t.length==200?'....':'';
    				return t;
                }
    		}) + "</" + this.containertag[0] + ">" + "\n\n"
    	}
    	rssoutput+=(this.containertag[0]=="li")? "</ul>" : ""
    	for (var i=0; i<this.regexprules.length; i++){ // loop thru remaining regexprules array that target the entire feed in general (versus specific field)
    		rssoutput=rssoutput.replace(this.regexprules[i][0], this.regexprules[i][1])
    	}
    	this.feedcontainer.innerHTML=rssoutput
    }
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  6. #6
    Join Date
    Jul 2010
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    John -

    I think we had enough script modifications at this point to make your suggestion above not work (( Changing snippet to description actually breaks things on the page. I've been following your suggestions posted in this thread: http://www.dynamicdrive.com/forums/s...Displayer-v2-0

    The page I'm trying to make things work on is http://cxcskiing.org/index.html

    Thank you!

Similar Threads

  1. Display Image with gAjax RSS Feeds Displayer v2.0
    By cxcskiing in forum Dynamic Drive scripts help
    Replies: 11
    Last Post: 07-16-2014, 05:20 PM
  2. gAjax RSS Feeds Displayer not working with my feed url...
    By nando99 in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 11-28-2012, 05:38 PM
  3. gAjax RSS Feeds Displayer - feed sometimes linked to wrong label
    By plimfec in forum Dynamic Drive scripts help
    Replies: 7
    Last Post: 06-15-2010, 06:22 AM
  4. gAjax RSS Feeds Displayer - Problem with protected feed
    By marcellow in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 07-08-2009, 12:54 PM
  5. gAjax RSS Feeds Displayer - can't display multiple feeds
    By nsbrown in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 06-06-2008, 08:40 AM

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
  •