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!
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
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:
For the title field, the number of characters shown is not controlled by the script and can't be altered.Code:myrssvar.displayoptions("datetime label description")
DD Admin
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:
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.Code:itemdescription=itemdescription.replace(re, "").substring(0, 200) if (itemdescription.length==200) itemdescription+='...'
Thank you!
Last edited by cxcskiing; 07-23-2014 at 03:35 PM.
Sounds like you're only displaying the snippet part instead of the description. Change that (using the second example from the demo page):
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 feedsocialfeed.displayoptions("label datetime snippet") //show the specified additional fieldssocialfeed.setentrycontainer("div") //Display each entry as a DIV socialfeed.filterfeed(6, "label") //Show 6 entries, sort by label socialfeed.init() //Always call this last
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 feedsocialfeed.displayoptions("label datetime description") //show the specified additional fieldssocialfeed.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
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/
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!
Bookmarks