PDA

View Full Version : date Placement: Pausing RSS Scroller



frik
03-25-2006, 03:33 AM
Script: Pausing RSS Scroller
http://www.dynamicdrive.com/dynamicindex17/rsspausescroller/

hi i was wondering if this possible at all: changing the date placement to appear *next* to the title. currently in the default script, if date is chosen to be displayed, it will display itself *under* the title

i've been looking at it for a bit, and i have a feeling it's something that i'd have to tweak in lastrss/scrollerbridge.php, ie/


---------------------
function outputRSS_JS($url, $divid) {
global $rss;
if ($rs = $rss->get($url)){
echo "rsscontentdata.$divid=new Array();\n";
$i=0;
foreach ($rs['items'] as $item) {
echo "rsscontentdata.$divid" . "[$i]={link:\"" . sla****($item[link]) . "\", title:\"" . sla****($item[title]) . "\", description:\"" . sla****($item[description]) . "\", date:\"" . sla****($item[pubDate]) . "\"}\n";
$i++;
}
if ($rs['items_count'] <= 0) { echo "rsscontentdata=\"Sorry, no items found in the RSS file\""; }
}
else {
echo "rsscontentdata=\"Sorry: It's not possible to reach RSS file $url\"";
// All else fails
}
}
---------------------


am i close? thanks!

frik
03-27-2006, 10:05 PM
omg, i finally found it! wooooooop

the layout actually resides in rsspausescroller.js

and the line
return linktitle+"<br />"+feedate obviously contains <br /> and i just removed it :D

now, i just need to figure out how to put a really big space between the linktitle and the feeddate

coz at the moment it looks like this:
Country radio still uneasy with Dixie Chicks Mar 27, 2006 11:24:10 PM
ie/the date is RIGHT next to the title

thanks everyone! ;)

jscheuer1
03-27-2006, 10:18 PM
You could try:


return linktitle+"<span style='margin-left:400px;'>"+feedate+"</span>"

adjusting 400 as needed. Padding-left might be better than margin-left.

Or, even get creative and calculate on the fly what remains from the widths taken up by the title and the date when subtracted from the container they reside in's width and use that as the left margin/padding.

frik
03-27-2006, 11:09 PM
...Or, even get creative and calculate on the fly what remains from the widths taken up by the title and the date when subtracted from the container they reside in's width and use that as the left margin/padding...

woahh that would be cool. how am i gonna do that if the title and date width is obviously not fixed (ie/dependent of the rss feed)?

jscheuer1
03-28-2006, 04:14 AM
Consider this:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<div class="floatContainer" style="width:500px;border:1px solid black;padding:2px 4px;font-family:verdana;color:red;font-weight:bold;font-size:80%;"><div style="float:left;width:300px;">Country radio still uneasy with Dixie Chicks. Blah, blah, blah.</div><span style="float:right;font-size:75%;font-weight:normal;">Mar 27, 2006 11:24:10 PM</span></div>
<script type="text/javascript">
var floatC=document.getElementsByTagName('div');
for (var i_tem = 0; i_tem < floatC.length; i_tem++)
if (floatC[i_tem].className=='floatContainer')
floatC[i_tem].style.height=floatC[i_tem].firstChild.offsetHeight+'px'
</script>
</body>
</html>

In the above example, the division with the class of 'floatContainer' represents the container in your script. Hopefully it already has a class name and a fixed width that you can set. If so, we can just replace floatContainer in the script code with its class name. With a bit of luck, we can then do this:


return '<div style="float:left;width:300px;">'+linktitle+'</div><span style="float:right;">'+feedate+'</span>'

Then find the function where the above line is returning to and have its next lines be:


var floatC=document.getElementsByTagName('div');
for (var i_tem = 0; i_tem < floatC.length; i_tem++)
if (floatC[i_tem].className=='floatContainer')
floatC[i_tem].style.height=floatC[i_tem].firstChild.offsetHeight+'px'

or this code can be run at another point, as long as it is after each update of the feed(s). The actual widths that you choose to use can be different, the container's width can be what ever it is, makes no difference except the linktitle's division must be narrow enough to fit inside it plus enough width left over for the feedate.

frik
03-28-2006, 08:39 AM
ahh nice thanks for that. i had to tweak a few things to adapt to the orginal scrolling .js;

based on your concept, it currently works perfect as just
return "<span style='float:left;'>"+linktitle+"</span><span style='float:right;'>"+feeddate+"</span>"

and i didnt even have to use the very last bit of code that you suggested! i dunno what's the long-term or cross-browser issues its gonna introduce now that ive simplified the concept to this extent, but for now it's working perfect on ff1.5 and ie6.

jscheuer1
03-28-2006, 11:47 AM
The only two things I would be concerned about are:

1 ) What if the headline needs to wrap?

2 ) If there is a container around the floating spans and one of them needs to wrap, how will the container know to increase its height in FF? In IE it will just do so, being filled by the content. However, in FF a float is like position:absolute in many ways so the content may write outside the lines.

frik
03-29-2006, 10:27 AM
ahh i see the logic now

but my page design isnt sposed to accomodate wrapping titles anyway, i dont think. it'll look pretty horrendous if the container was to increase its height.

at the moment, i'm solely depending on the title to have a maximum length (pretty long now actually, at around 400px just reserved for the title). dunno, this is becoming more and more of a design thing than a technical one.

i know its a better practice to foolproof everything but the design has gone so deep and the client has been approving all (big and small) stages so far. going back one design step will mean a week or two extra developing time.

plus, the 'external' rss feed is ultimately going to be from our own servers anyway, which means all titles will be fully under my control! hopefully it works out well!