Pilot Roster Loop

Hello guys

I am trying to make the pilot roster to show only the pilots and i have managed this the only problem is that it keeps looping the pilot_list.tpl

i have also tried to insert my own page into it like <?php echo “Hello World”; ?> and this keeps looping asswel so i am sure that the code is corect

This is the code of the pilot_list.tpl

<?php $roster = PilotData::getAllPilots(); ?>
<?php
  if(!$roster)
  {
     echo 'There are no pilots!';
     return;
  }
?> 
<table id="tabledlist" class="tablesorter">
<thead>
<tr>
  <th>Pilot ID</th>
  <th>Name</th>
  <th>Rank</th>
  <th>Flights</th>
  <th>Hours</th>
  <th>HUBs</th>
</tr>
</thead>
<tbody>
<?php foreach($roster as $pilot) { ?>
<tr>
  <td width="1%" nowrap>
      <img src="<?php echo Countries::getCountryImage($pilot->location);?>"
        alt="<?php echo Countries::getCountryName($pilot->location);?>" />
 <a href="<?php echo SITE_URL?>/index.php/profile/view/<?php echo $pilot->pilotid?>">
        <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
  </td>
  <td>


     <center><?php echo $pilot->firstname.' '.$pilot->lastname?></center>
  </td>
  <center><td><img src="<?php echo $pilot->rankimage?>" alt="<?php echo $pilot->rank;?>" /></td></center>
  <center><td><?php echo $pilot->totalflights?></td></center>
  <center><td><?php echo Util::AddTime($pilot->totalhours, $pilot->transferhours); ?></td></center>
  <center><td><?php echo $pilot->hub?></td></center>
</tr>
<?php } ?>
</tbody>
</table>

any help would be gratefull

Thanks in advance

Vangelis Boulasikis

http://aviation-global-airways.com

Your page is good. I think it is how you are calling it. Are you still using the address as www.yoursite.com/index.php/pilots ? If so, you are calling the functions within the module which will seperate the pilots into hubs everytime. Best bet is to create a new path to the page. Either using the page function in admin or through a new module. I pasted your code into a blank page without using the pilots module and it works fine… Hope this helps a little.

Your page is good. I think it is how you are calling it. Are you still using the address as www.yoursite.com/index.php/pilots ? If so, you are calling the functions within the module which will seperate the pilots into hubs everytime. Best bet is to create a new path to the page. Either using the page function in admin or through a new module. I pasted your code into a blank page without using the pilots module and it works fine… Hope this helps a little.

could you please help on how to do that or an example of this ?

Thanks in advance

Vangelis Boulasikis

P.S Temporarly i stoped the problem by leaving only 1 hub but like that we can not gice the option to the new pilots to select their hub

You have to modify the module to get it to work right… if you do a search it’s come up before

You have to modify the module to get it to work right… if you do a search it’s come up before

Do u have a name for that module ?

Thanks

Without creating another module or a new page for your site you can open pilots.php in your core/modules/pilots folder and find the index section ->

public function index()
{
	// Get all of our hubs, and list pilots by hub
	$allhubs = OperationsData::GetAllHubs();

	if(!$allhubs) $allhubs = array();

	foreach($allhubs as $hub)
	{
		$this->set('title', $hub->name);
		$this->set('icao', $hub->icao);

		$this->set('allpilots', PilotData::findPilots(array('p.hub'=>$hub->icao)));

		$this->render('pilots_list.tpl');
	}

	$nohub = PilotData::findPilots(array('p.hub'=>''));
	if(!$nohub)
	{
		return;
	}

	$this->set('title', 'No Hub');
	$this->set('icao', '');
	$this->set('allpilots', $nohub);
	$this->render('pilots_list.tpl');
}

and change it to

public function index()
{
            $this->set('allpilots', PilotData::getAllPilots());
      $this->render('pilots_list.tpl');
        }

Just remember when you update this will be overwritten to the default structure. You would be better served to create a new page and/or module.

That worked

Thanks a lot for your help

Vangelis Boulasikis

I am going to make a tutorial about how to make some custom pages, and changes.