Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

stuck at adding a RSS ticker to template


Reply


5 Posts   1131 Views

Avatar
qlex

Community Member, 68 Posts

17 August 2009 at 5:58am

Hi,
I am stuck at adding that RSS ticker JS to template.
Would really appreciate if somebody could let me know what am i doing wrong, as I've been scratching my head on this for whole weekend ! :)

Here's what i did so far:

To mysite/javascript I have put two files: rssticker.js and direction in mysite/javascript/lastrss/ with bridge.php and lastRSS.php files

To my theme/client/templates/Page.ss i have put in <head>:

<script src="mysite/javascript/rssticker.js" type="text/javascript">

/***********************************************
* Advanced RSS Ticker (Ajax invocation)- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

</script>

<style type="text/css">

/*Sample CSS to style the two tickers in the demo*/

.cnnclass{
width: 400px;
padding: 5px;
background-color: #F3F3F3;
border: 1px solid black;
margin-bottom: 1em;
filter:progid:DXImageTransform.Microsoft.alpha(opacity=80); /*Specify fade effect in IE. Remove if desired.*/
-moz-opacity: 0.8; /*Specify fade effect in Firefox. Remove if desired.*/
}

.cnnclass a{
text-decoration: none;
}

.bbcclass{
width: 400px;
padding: 6px;
background-color: lightyellow;
border: 1px solid #004A00;
}

.rsstitle{ /*shared class for all title elements in an RSS feed*/
font-weight: bold;
}

.rssdate{ /*shared class for all date elements in an RSS feed*/
color: gray;
font-size: 85%;
}

.rssdescription{ /*shared class for all description elements in an RSS feed*/
}

</style>

And in <body>:

<div style="height: 150px">
<script type="text/javascript">
//rssticker_ajax(RSS_id, cachetime, divId, divClass, delay, optionalswitch)
//1) RSS_id: "Array key of RSS feed in PHP script"
//2) cachetime: Time to cache the feed in minutes (0 for no cache)
//3) divId: "ID of DIV to display ticker in. DIV dynamically created"
//4) divClass: "Class name of this ticker, for styling purposes"
//5) delay: delay between message change, in milliseconds
//6) optionalswitch: "optional arbitrary" string to create additional logic in call back function

document.write("CNN News: (Fade Effect enabled. Title+date shown)")
new rssticker_ajax("CNN", 600, "cnnbox", "cnnclass", 3000, "date")

document.write("<br />BBC News: (Title+date+description shown)")
new rssticker_ajax("BBC", 1200, "ddbox", "bbcclass", 3500, "date+description")

</script>
</div>

This causes that new div to appear on website. I can see that rssticker.js from <head> and the script from <body> are both visible in firebug. All connections to those other php files, Im calling in using /mysite/javascript/ path with site root defined.

I cant make those feeds to appear on my site.

The RSS JS files are taken from:
[url]http://www.dynamicdrive.com/dynamicindex17/rsstickerajax/index.htm[/url]

Please help ! Im desperate!

Qlex

Avatar
Willr

Forum Moderator, 5513 Posts

17 August 2009 at 9:15am

Are you trying to use BlackCandy or serving your template as xml?. document.write will not work if this is the case.

Avatar
qlex

Community Member, 68 Posts

17 August 2009 at 6:57pm

Hi Willr,
i am not using blackcandy (i have rewritten template based on paddygreen theme idea) at www.ztm.poznan.pl.

My header has:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >

If xml doesnt allow document.write, what do you suggest? At the moment, im using rsspump.com generator that creates an iframe which i added to sidebar.

Qlex

Avatar
Willr

Forum Moderator, 5513 Posts

17 August 2009 at 7:01pm

Remove this line

<?xml version="1.0" encoding="UTF-8"?>

and it should work

Avatar
qlex

Community Member, 68 Posts

17 August 2009 at 7:06pm

Hi,
removed the line and feed forms were displayed but inside i got:

CNN News: (Fade Effect enabled. Title+date shown)
Error fetching remote RSS feed!