Paginated Flights Page.

Im trying to create a page viewable from the main site of all the flights in the system, which i’ve done, but i only want to view X at a time with next and prev links undereath is this possible with the way PHPVMS is done?

or would it be easer to do it in my own code?

my current code:

<?
class Flights extends CodonModule
{

public function Controller()
{
$schedules = SchedulesData::GetSchedules('', true);

	if(!is_array($schedules))
		return false;

	foreach($schedules as $sched)
	{
		$vars = get_object_vars($sched);

		$xml .= '<schedule>'.PHP_EOL;
		foreach($vars as $name=>$val)
		{
			$val = strip_tags($val);

			if($name == 'id' || $name == 'leg' || $name == 'enabled'
					|| $name == 'flighttime' || $name == 'timesflown'
					|| $name == 'depname' || $name == 'deplat'
					|| $name == 'deplong' || $name == 'arrname' 
					|| $name == 'arrlat' || $name == 'arrlong')
			{
				continue;
			}

			$xml .= "<{$name}>{$val}</{$name}>".PHP_EOL;
		}

		$xml .= '</schedule>'.PHP_EOL;
	}		

	$xml .= '</schedules>';	

?>

<h3><?php echo $title?></h3>
<?php
if(!$schedules)
{
echo '<p id="error">No schedules exist</p>';
return;
}
?>
<table id="tabledlist" class="tablesorter">
<thead>
<tr>
<th>Flight Number</th>
<th>Departure</th>
<th>Arrival</th>
<th>Days</th>
<th>Aircraft</th>
<th>Distance</th>
<th>Times Flown</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<?php
foreach($schedules as $sched)
{
?>
<tr id="row<?php echo $sched->id?>" class="<?php echo ($sched->enabled==0)?'disabled':''?>">
<td align="left"><?php echo $sched->code . $sched->flightnum; ?></td>
<td align="left"><?php echo $sched->depicao; ?> (<?php echo $sched->deptime;?>)</td>
<td align="left"><?php echo $sched->arricao; ?> (<?php echo $sched->arrtime;?>)</td>
<td align="left"><?php echo Util::GetDaysCompact($sched->daysofweek)?></td>
<td align="left"><?php echo $sched->aircraft.' ('.$sched->registration.')'; ?></td>
<td align="center"><?php echo $sched->distance; ?></td>
<td align="center"><?php echo $sched->timesflown; ?></td>
<td align="center">
	<?php echo $sched->flighttype . ' ('.$sched->maxload.'/'.$sched->price.')'; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>

<?	}
}
?>

its just a slightly modified version of the admin schedule list.

Easiest way would be using this:

http://tablesorter.com/docs/

And you can see in the code, that the tablesorter class is in the <table> tag, you should just have to include the javascript file, then it should just work…

Why is there XML output in the middle of your code?

There should be a start parameter for the GetSchedules -

GetSchedule(start, limit, only_enabled), IIRC

to be perfectly honest i don’t know about the XML lol i was just copying some of the code from the admin listing page, i thought it was needed but now i realise its not.

Ill have a look at that link you posted and let you know how i get on.

I’ve given that a try and i can’t make a heads or tails of it, no matter what i try even copying the code from the demo pages they provide yet it doesn’t work?

as far as i can tell all the file references are corerct

<?
class Flights extends CodonModule
{

public function Controller()
{
$schedules = SchedulesData::GetSchedules('', true);

	if(!is_array($schedules))
		return false;


?>

<h3><?php echo $title?></h3>
<?php
if(!$schedules)
{
echo '<p id="error">No schedules exist</p>';
return;
}
?>
<style type="text/css">@import "/OpsCenter/core/modules/Flights/docs/assets/css/default.css";</style>
<style type="text/css">@import "/OpsCenter/core/modules/Flights/addons/pager/jquery.tablesorter.pager.css";</style>
<script type="text/javascript" src="/jquery-latest.js"></script>

<script type="text/javascript" src="/jquery.dimensions.pack.js"></script>
<script type="text/javascript" src="/jquery.tablesorter.js"></script>
<script type="text/javascript" src="/OpsCenter/core/modules/Flights/addons/pager/jquery.tablesorter.pager.js"></script>
<script type="text/javascript">
$(document).ready(function() { 
    $("tabledlist") 
    .tablesorter({widthFixed: true, widgets: ['zebra']}) 
    .tablesorterPager({container: $("#pager")}); 
}); 
</script>	



<table id="tabledlist" class="tablesorter">
<thead>
<tr>
<th>Flight Number</th>
<th>Departure</th>
<th>Arrival</th>
<th>Days</th>
<th>Aircraft</th>
<th>Distance</th>
<th>Times Flown</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<?php
foreach($schedules as $sched)
{
?>
<tr id="row<?php echo $sched->id?>" class="<?php echo ($sched->enabled==0)?'disabled':''?>">
<td align="left"><?php echo $sched->code . $sched->flightnum; ?></td>
<td align="left"><?php echo $sched->depicao; ?> (<?php echo $sched->deptime;?>)</td>
<td align="left"><?php echo $sched->arricao; ?> (<?php echo $sched->arrtime;?>)</td>
<td align="left"><?php echo Util::GetDaysCompact($sched->daysofweek)?></td>
<td align="left"><?php echo $sched->aircraft.' ('.$sched->registration.')'; ?></td>
<td align="center"><?php echo $sched->distance; ?></td>
<td align="center"><?php echo $sched->timesflown; ?></td>
<td align="center">
	<?php echo $sched->flighttype . ' ('.$sched->maxload.'/'.$sched->price.')'; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div id="pager" class="pager">
<form>
	<img src="/OpsCenter/core/modules/Flights/addons/pager/icons/first.png" class="first"/>
	<img src="/OpsCenter/core/modules/Flights/addons/pager/icons/prev.png" class="prev"/>
	<input type="text" class="pagedisplay"/>
	<img src="/OpsCenter/core/modules/Flights/addons/pager/icons/next.png" class="next"/>
	<img src="/OpsCenter/core/modules/Flights/addons/pager/icons/last.png" class="last"/>
	<select class="pagesize">
		<option selected="selected"  value="5">5</option>
		<option value="20">10</option>
		<option value="30">15</option>
		<option  value="40">20</option>
	</select>
</form>
</div>
<?	}
}
?>

To refer to a file use SITE_URL then the path:

<style type="text/css">@import "<?php echo SITE_URL?>/assets/css/default.css";</style>

That’s probably why

Ahhh that was the problem, only remaing problem i have now is getting the links at the bottom to stay under the table as they keep moving over the copyright etc :S

Check your CSS, a couple of hard line breaks will help too..

<p style=“clear:both;”></p>