Jump to content

RSS Marquee HEEEELP!


BoarderLine

Recommended Posts

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("&quot;", """, $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>

Link to comment
Share on other sites

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("&quot;", """, $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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.