I have some dynamic XML - generated in a PHP script. The script takes a single param 'p' - for 'pagenum'. The idea is to show paginated data - allowing the user to select next/previous page of data.
What approach do I take to updating the data with new pages - is it possible that my screen will update with having to reload the page over HTTP?
Here's a snippet of my main page - basically I'm reloading the whole page with a new GET param. (p=1, p=2 etc). (As can be seen, my main page also happens to be PHP - but I'm really doing a whole lot except grabbing the param).
<?php
header('Content-Type: text/xml; charset=utf-8');
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$p=1;
if (isset($_GET['p'])) {
try { $p=(int)$_GET['p']; } catch(Exception $ex) { ; }
}
if (isset($_GET['debug'])) { $debug="yes"; } else { $debug="no"; }
?>
[...]
<xf:model>
<xf:instance src="data.php?p=<?=$p?>"/>
</xf:model>
</head>
<body>
<xf:repeat ref="videos/video">
<details>
<summary>
<span class="title"><xf:output value="title"/></span>
</summary>
<p>
<xf:output value="description" mediatype="text/html"/>
</p>
</details>
</xf:repeat>
EDIT: adding dummy datasource for reference.
<?php
header('Content-Type: text/xml; charset=utf-8');
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if (isset($_GET['p'])) { $p=(int)$_GET['p']; } else { $p=1; }
echo "<data xmlns=''>\n";
echo "<videos>\n";
switch ($p) {
case 1:
echo "<video><title>Macbeth</title></video><video>Malformed</video>";
break;
case 2:
echo "<video><title>Hamlet</title></video><video>SPACE 2003</video>";
break;
case 3:
echo "<video><title>Romeo And Juliet</title></video><video>Back to the Feature</video>";
default:
echo "<video/>";
}
echo "</videos>\n";
echo "</data>\n";
?>
I got something working - not sure this is the right approach here or not. Posting in case useful for others - and if anybody could advise improvements. I ditched the idea of using URL params on the view itself - instead, altered the model to include 'pagenum' in a 'metadata' section in the instance itself.
XForm Code:
Data-source:
Screenshot: