BoarderLine Posted December 4, 2008 Share Posted December 4, 2008 Hi all, I am displaying the marquee below on my site which is operating fine however as it is currently the marquee only displays a single feed item in the marquee (when set to display 10 at once as indicated the first displays ok and the remaining 9 are scrolling below), does anyone have any clue how I would change this code to link the feed items into a single marquee/line/string. Thanks. <marquee> <?PHP $MAXLINKCOUNT = 10; // (* 2) if =10, 5 news items will show $MAX_DESC_CHARS = 120; $insideitem = false; $tag = ""; $title = ""; $description = ""; $link = ""; $linkcount = 0; function startElement($parser, $name, $attrs) { global $insideitem, $tag, $title, $description, $link; if ($insideitem) { $tag = $name; } elseif ($name == "ITEM") { $insideitem = true; } } function endElement($parser, $name) { global $insideitem, $tag, $title, $description, $link, $linkcount, $MAXLINKCOUNT, $MAX_DESC_CHARS; if ($name == "ITEM" && $linkcount <= $MAXLINKCOUNT) { if (strlen($description) > $MAX_DESC_CHARS) { $description = wordwrap($description, $MAX_DESC_CHARS, "-=CUT OFF HERE=-"); $pos = strpos($description, "-=CUT OFF HERE=-"); $description = trim(substr($description, 0, $pos)) . "..."; } $description = htmlspecialchars(trim($description)); $description = str_replace(""", """, $description); printf("<dt><b><a href='%s'>%s</a></b></dt>", trim($link),htmlspecialchars(trim($title))); printf("<dt>%s</dt><br>",$description); $title = ""; $description = ""; $link = ""; $insideitem = false; } } function characterData($parser, $data) { global $insideitem, $tag, $title, $description, $link, $linkcount; if ($insideitem) { switch ($tag) { case "TITLE": $title .= $data; break; case "DESCRIPTIon": $description .= $data; break; case "LINK": $link .= $data; $linkcount++; break; } } } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); $fp = fopen("http://tvnz.co.nz/content/455321/rss_20_skin.xml", "r") or die("Error reading rss data."); while ($data = fread($fp, 2048)) { xml_parse($xml_parser, $data, feof($fp)); } fclose($fp); xml_parser_free($xml_parser); ?></marquee> Quote Link to comment Share on other sites More sharing options...
haku Posted December 4, 2008 Share Posted December 4, 2008 Honestly, you should just drop it. Marquees went out of style in the '90s. Quote Link to comment Share on other sites More sharing options...
BoarderLine Posted December 4, 2008 Author Share Posted December 4, 2008 im bringing them back - anyone else??? Quote Link to comment Share on other sites More sharing options...
haku Posted December 4, 2008 Share Posted December 4, 2008 Good luck Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 4, 2008 Share Posted December 4, 2008 <marquee> ? What's that? I can't see it in (X)HTML specification. Quote Link to comment Share on other sites More sharing options...
haku Posted December 4, 2008 Share Posted December 4, 2008 That's because it's been deprecated. It's a presentational tag, and XHTML is for content only, not presentation. Same reason there is no font tag, or bold tag, or underline tag. Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 4, 2008 Share Posted December 4, 2008 Tsk, tsk... haku... I know that BoarderLine: if you really feel like doing a marquee, use JavaScript and CSS. Quote Link to comment Share on other sites More sharing options...
PravinS Posted December 4, 2008 Share Posted December 4, 2008 You want like this, try this updated code <marquee behavior="scroll" scrollamount="5"> <?PHP $MAXLINKCOUNT = 10; // (* 2) if =10, 5 news items will show $MAX_DESC_CHARS = 120; $insideitem = false; $tag = ""; $title = ""; $description = ""; $link = ""; $linkcount = 0; function startElement($parser, $name, $attrs) { global $insideitem, $tag, $title, $description, $link; if ($insideitem) { $tag = $name; } elseif ($name == "ITEM") { $insideitem = true; } } function endElement($parser, $name) { global $insideitem, $tag, $title, $description, $link, $linkcount, $MAXLINKCOUNT, $MAX_DESC_CHARS; if ($name == "ITEM" && $linkcount <= $MAXLINKCOUNT) { if (strlen($description) > $MAX_DESC_CHARS) { $description = wordwrap($description, $MAX_DESC_CHARS, "-=CUT OFF HERE=-"); $pos = strpos($description, "-=CUT OFF HERE=-"); $description = trim(substr($description, 0, $pos)) . "..."; } $description = htmlspecialchars(trim($description)); $description = str_replace(""", """, $description); printf("<td><b><a href='%s'>%s</a></b></td>", trim($link),htmlspecialchars(trim($title))); printf("<td>%s</td>",$description); $title = ""; $description = ""; $link = ""; $insideitem = false; } } function characterData($parser, $data) { global $insideitem, $tag, $title, $description, $link, $linkcount; if ($insideitem) { switch ($tag) { case "TITLE": $title .= $data; break; case "DESCRIPTIon": $description .= $data; break; case "LINK": $link .= $data; $linkcount++; break; } } } print('<table cellpadding="3"><tr>'); $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); $fp = fopen("http://tvnz.co.nz/content/455321/rss_20_skin.xml", "r") or die("Error reading rss data."); while ($data = fread($fp, 2048)) { xml_parse($xml_parser, $data, feof($fp)); } fclose($fp); xml_parser_free($xml_parser); print('</tr></table>'); ?></marquee> Quote Link to comment Share on other sites More sharing options...
BoarderLine Posted December 5, 2008 Author Share Posted December 5, 2008 AWesome pbs you rule - Thats perfect, thanks for your HELP Quote Link to comment Share on other sites More sharing options...
BoarderLine Posted December 5, 2008 Author Share Posted December 5, 2008 Mchl- Wouldn't the RSS feed content be lost to search engines using Javascript??? Quote Link to comment Share on other sites More sharing options...
haku Posted December 5, 2008 Share Posted December 5, 2008 Depends on how you code it. If you put the text in non-marqueed, then add javascript to give it the marquee effect after the fact, search engines will still be able to index it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.