Pilot List by Custom Field Data

Hello,

For my VA i want to change the pilot list to show the pilots not by all of our hubs but by an Custom Field Value. The name of this field is Status and the three possible Values are “IVAO Pilot” “Active Pilot” and “Inactive Member”. It would be great if you could help us.

Thank you,

Bastian Wagne (Cologne International VA)

Hello Bastian, and welcome to this forum:

In order to achieve what you are trying to do…

…1st step: You´ll have too look for the pilot_list.tpl of your current skin, and then you will probably have an HTML table, like this one for example:

<table id="tabledlist" class="table table-bordered">
<thead>
<tr>
<th>Pilot ID</th>
<th>Name</th>
<th>Rank</th>
<th>VATSIM ID</th>
<th>IVAO</th>
<th>Flights</th>
<th>Hours</th>
</tr>
</thead>
<tbody>

So what you have to do is add a new <th> called Status, so like this: <th>status</th>

2n steep: Look for the php code at the bottom of the file, you´ll have to add there something like this, being carefully of respecting the order of the <th> created before with the <td> on this section of the code if you know what I mean:

<td>
  <?php echo PilotData::GetFieldValue($pilot->pilotid, 'Status'); ?>
 </td

Kind regards, and let me know if it worked!

I think you’ve missunderstood me. My goal is to list the pilots by their status. Currently they are grouped by hub (All pilots for Hub XXXX), but I want to group them by this coustom field value (e.g. All IVAO-Pilots, etc.) if you know what I mean.

Bastian Wagner

Sorry for the delay I am really busy with some other proyects.:

Ok, let´s try this, Go to:

Core->Modules->Pilots and open Pilots.php

Then, inside the public function index modify the code look like this:

class Pilots extends CodonModule
{
public function index()
{
$pdo = new PDO('mysql:host=$host; dbname=$database;', $user, $pass);
$stmt = $pdo->prepare('SELECT "pilotid" FROM "phpvms_fieldvalues" WHERE "value" = "IVAO Pilot"');
$stmt->execute();
$result = $stmt->fetchAll();


if(!$result) $result = array();
foreach($result as $res)
{
$this->set('title', 'IVAO Pilot');

$this->set('allpilots', $res);

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

P.S: Notice this is a kind of pseudo-code that I haven´t had the chance to try it, so it might not work correctly at all.

Regards!