I haven't posted anything in a while but now I am running into a problem.
The CSM that I work with a lot is Joomla. I have been using Magicparser to take xml files and convert them into RSS. The reason is that Joomla has a built in RSS reader and RSS feeds are counted as content and appear on the page exactly as content. Thus giving the SE spiders something to see and index.
Now for the problem, I am building a new site that will be using these RSS feeds but I would like to add pagination to the RSS feed. I have searched for days and I have no idea if this is even possible. I have looked at some of the code posted in this forum on pagination and have tried to work these examples into my code, but the Next and Previous links are not appearing. The additions are cutting the feed off at 10 as it is suppose to but there are no links appearing to go to the next page or previous page.
Below is a copy of the code I am using. Can someone please tell me what I am doing wrong or is it even possible to add pagination to a RSS feed?
<?php
header("Content-Type: text/xml");
function xmlentities($text)
{
$search = array('&','<','>','"','\'');
$replace = array('&','<','>','"',''');
$text = str_replace($search,$replace,$text);
return $text;
}
//require("MagicParser.php");
require("MagicParser.php");
$page = $_GET["page"];
$counter = 0;
$itemsOnPage = 10;//Set the number of items displayed per page
// default to the first page
if (!$page) $page = 1;
function myRecordHandler($video)
{
global $page;
global $counter;
global $itemsOnPage;
$counter++;
// return false whilst parsing items on previous pages
if ($counter < (($page-1)*$itemsOnPage)) return false;
print "<item>";
print "<author>Search Video</author>";
print "<title>".xmlentities($video["TITLE"], "UTF-8")."</title>";
print "<link>".xmlentities($video["VIDEOURL"], "UTF-8")."</link>";
print "<description>";
print "<![CDATA[";
print "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
print "<tr>";
print "<td rowspan=\"6\" valign=\"top\"><img src='".$video["THUMBNAILURL"]."' border=\"0\" width=\"120\" height=\"90\"></td><td rowspan=\"6\"> </td></tr>";
print "<tr><td>";
print "".$video["TITLE"]."</td></tr>";
print "</td></tr>";
print "<tr><td>";
print "<b>Runtime:</b> ".$video["RUNTIME"]." seconds";
print "</td></tr>";
print "<tr><td>";
print "".$video["DESCRIPTION"]." ";
print "</td></tr>";
print "<tr><td>";
print "<b>Category:</b> ".$video["CATEGORY"]." - <b>Channel:</b> ".$video["CHANNEL"]."";
print "</td></tr>";
print "<tr><td>";
print "<b>Tags:</b> ".$video["TAGS"]." ";
print "</td></tr></table>";
print "]]>";
print "</description>";
print "</item>";
// return true if counter reaches current page * items on each page
return ($counter == ($page*$itemsOnPage));
}
print "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
print "<rss version= \"2.0\" xmlns:media=\"http://search.yahoo.com/mrss/\">";
print "<channel>";
print "<title>Search Video</title>";
print "<h1>Search Video</h1>";
print "<link></link>";
print "<image>";
print "<url>http://video.google.es/common/logo_video.jpg</url>";
print "<link>http://www.searchvideo.com</link>";
print "<title>Search Video</title>";
print "<height>63</height>";
print "<width>123</width>";
print "</image>";
print "<description>Videos</description>";
// display link to next page
print "<p><a href='?page=".($page+1)."'><h1 align=\"center\">Next</h1></a></p>";
//Parse the xml feed
MagicParser_parse("http://beta.searchvideo.com/apiv3?appid=d2c23d487bd7ff733&method=truveo.videos.getVideos&query=honda%20goldwing%20sort:mostRecent&results=50","myRecordHandler","xml|RESPONSE/VIDEOSET/VIDEO/");
print "</channel>";
print "</rss>";
?>
Any help would be greatly appreciated.
Thank you
No what the above script produces is then fed into Joomla as a feed and displayed as a RSS feed. Maybe I will just try the html version of the pagination example and see how that works.
Hi,
The pagination code is designed for HTML output - but I see in this code you are actually
creating a new XML document from another one... so this file isn't the place for the
pagination code.
Did you mean to insert this into another script that displays the content of this new
feed as an HTML page?
Cheers,
David.