PDA

View Full Version : Advanced RSS Ticker (Ajax invocation) : how to show categories



youyoup
02-12-2007, 10:03 PM
1) Script Title: Advanced RSS Ticker (Ajax invocation)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/rsstickerajax/index.htm

3) Describe problem:
how to show category for each item ?

ddadmin
02-12-2007, 10:47 PM
This is untested, though it should work. :) Try the below:

1) Inside bridge.php, find and edit the line:


foreach ($rs['items'] as $item) {
echo "<item>\n<link>$item[link]</link>\n<title>$item[title]</title>\n<description>$item[description]</description>\n<pubDate>$item[pubDate]</pubDate>\n<category>$item[category]</category>\n </item>\n\n";

Code in red is new.

2), Inside rssticker.js, find and edit:


this.title=[], this.link=[], this.description=[], this.pubdate=[], this.category=[]

And


this.pubdate[i]=this.feeditems[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue
this.category[i]=this.feeditems[i].getElementsByTagName("category")[0].firstChild.nodeValue

Code in red is new.

And:


var feeddate='<div class="rssdate">'+this.pubdate[this.pointer]+'</div>'
var category='<div class="rsscategory">'+this.category[this.pointer]+'</div>'
if (this.logicswitch.indexOf("description")==-1) description=""
if (this.logicswitch.indexOf("date")==-1) feeddate=""
var tickercontent=linktitle+feeddate+category+description //STRING FOR FEED CONTENTS

Again, code in red is new.

youyoup
02-13-2007, 06:40 AM
Thanks, i have put the new code but
the ticker is showing "Initializing ticker... "

Should i change something in the index.html to call categories ?

new rssticker_ajax("lepouvoirprix", 1200, "ddbox", "bbcclass", 3500, "date+description")

to

new rssticker_ajax("lepouvoirprix", 1200, "ddbox", "bbcclass", 3500, "date+category+description")

ddadmin
02-13-2007, 10:56 PM
Nope, you shouldn't have to specify "category" within the list of parameters when invoking the script to display it. I'll have to check back later tonight when I can physically run the modification within a web server to see what's wrong.

ddadmin
02-15-2007, 09:39 AM
Apparently I left out a line to edit inside rssticker.js, which is:


this.title=[], this.link=[], this.description=[], this.pubdate=[], this.category=[]

I've edited my post above as well to correct this. The result does work, which I've just test run. However, with the modication above, if an RSS feed doesn't contain a category element (not all do), the script will return an error. I've attached a modified version of rssticker.js that takes this into account. Use that instead.

youyoup
02-15-2007, 10:21 AM
it works fine !!! thanks a lot !!!

Last question : how can i change months in french :

ie : Feb to Fev

ddadmin
02-15-2007, 12:00 PM
Under which component (ie: category, title etc) do the months appear inside the RSS feed? What you can do is edit the frontpage rssticker.js file to scan for replaces instances of certain words with another word of your choice.