Jump to content

Recommended Posts

  • Members
Posted

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

  • Administrators
Posted

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. ;)

  • Members
Posted

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

  • Administrators
Posted

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. ;)

Guest Brian
Posted

All that really needs to be done is to render the object into the template.

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.

Loading...
×
×
  • Create New...