Jump to content

Newest Pilots List


TAV1702

Recommended Posts

Hi guys. I have a slight situation going on here.

On my front page, I got rid of the recent pilots as it was originally and created a table instead. Now instead of it showing only the 5 most recent pilots, it is showing all the pilots. I have accidentally created basically another pilots roster.

How can I create this and keep it looking good in a table and only have it show the 5 most recent pilots like it originally does out of the box?

 <div class="mainblock">
       <h2>Newest Pilots:</h2>
       <div class="block">
	<table>
       <thead>
    <tr>
      <th width="50%" scope="col">Pilot ID#</th>
      <th width="50%" scope="col">Name</th>
    </tr>
   </thead>
 <tbody>
 <?php

foreach($allpilots as $pilot)

{
/* 

     To include a custom field, use the following example:

 <td>

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



     For instance, if you added a field called "IVAO Callsign":



        echo PilotData::GetFieldValue($pilot->pilotid, 'IVAO Callsign');

   */

?>
  <tr>
     <td><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
    <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
  </td>
   <td><?php echo $pilot->firstname.' '.$pilot->lastname ?>
    </td>
  </tr>
  <?php

}

?>
 </tbody>
</table>

</div>
</div>

This is what I am using as we speak. Like I said, it will not limit to 5 pilots. I know why, but as it was originally, I could not get it to work in a table.

Link to comment
Share on other sites

If you're using frontpage_recentpilots.tpl this should work:


<div class="mainblock">
       <h2>Newest Pilots:</h2>
       <div class="block">
               <table>
       <thead>
    <tr>
      <th width="50%" scope="col">Pilot ID#</th>
      <th width="50%" scope="col">Name</th>
    </tr>
   </thead>
 <tbody>
 <?php

foreach($pilots as $pilot)

{
/* 

     To include a custom field, use the following example:

 <td>

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



     For instance, if you added a field called "IVAO Callsign":



        echo PilotData::GetFieldValue($pilot->pilotid, 'IVAO Callsign');

   */

?>
  <tr>
     <td><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
    <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
  </td>
   <td><?php echo $pilot->firstname.' '.$pilot->lastname ?>
    </td>
  </tr>
  <?php

}

?>
 </tbody>
</table>

</div>
</div>

Link to comment
Share on other sites

If you're using frontpage_recentpilots.tpl this should work:


<div class="mainblock">
       <h2>Newest Pilots:</h2>
       <div class="block">
               <table>
       <thead>
    <tr>
      <th width="50%" scope="col">Pilot ID#</th>
      <th width="50%" scope="col">Name</th>
    </tr>
   </thead>
 <tbody>
 <?php

foreach($pilots as $pilot)

{
/* 

     To include a custom field, use the following example:

 <td>

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



     For instance, if you added a field called "IVAO Callsign":



        echo PilotData::GetFieldValue($pilot->pilotid, 'IVAO Callsign');

   */

?>
  <tr>
     <td><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
    <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
  </td>
   <td><?php echo $pilot->firstname.' '.$pilot->lastname ?>
    </td>
  </tr>
  <?php

}

?>
 </tbody>
</table>

</div>
</div>

Well, I should clarify what I am referring to. :D

Originally, we could use a call in the side bar area to show the most recent 5 pilots. In the call it had the (5) in it. That told it to only show us 5 recent pilots.

Now with my table, that option is gone and it is pulling all 5 pilots. Please keep in mind that I have never edited the frontpage recent pilots tpl file.

That code I gave is what I put in my layout.tpl file for my side bar area statistics.

I would give the original code Nabeel used to use but I can no longer find it.

Link to comment
Share on other sites

Ahhh I found it.

<h3>Newest Pilots</h3>

<?php MainController::Run('Pilots', 'RecentFrontPage', 5); ?>

That is the code Nabeel used to call the 5 most recent pilots in the frontpagemain.tpl file.

Notice with my code, I did not tell it to only show me 5 pilots. That is where I am in trouble at. In my side bar area, ALL the pilots are now being listed instead of 5.

Link to comment
Share on other sites

Why don't you just use the original frontpage recent pilots and edit frontpage_recentpilots.tpl to suit? Makes life easier.

Well, I like my table how it is now, I simly need it to only call 5 pilots. I am not sure how I would do that to be honest.

Here is my frontpage_recentpilots.tpl

<?php

foreach($pilots as $pilot)
{
if($pilot->confirmed != 1)
   continue;
?>
<p><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>"><?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid). ' ' .$pilot->firstname . ' ' . $pilot->lastname?></a></p>
<?php
}
?>

Link to comment
Share on other sites

Are you using the current frontpage_recentpilots.tpl?

If not, you do exactly what you want by pasting the code for your table into frontpage_recentpilots.tpl and making sure the variables are correct (i.e. as I posted before)

Link to comment
Share on other sites

Well, I made a mistake on the last try. I edited the wrong frontpage_recentpilots.tpl. I edited the one in core, not in my skin folder.

I now went back and edited the one in my skin folder and the table is there, but once again it is showing every pilot.

Should I have delted the orginal code from that file, or left it there?

Link to comment
Share on other sites

Uh...

<div class="mainblock">
       <h2>Newest Pilots:</h2>
       <div class="block">
               <table>
       <thead>
    <tr>
      <th width="50%" scope="col">Pilot ID#</th>
      <th width="50%" scope="col">Name</th>
    </tr>
   </thead>
 <tbody>
 <?php

foreach($pilots as $pilot)

{
/* 

     To include a custom field, use the following example:

 <td>

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



     For instance, if you added a field called "IVAO Callsign":



        echo PilotData::GetFieldValue($pilot->pilotid, 'IVAO Callsign');

   */

?>
  <tr>
     <td><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
    <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
  </td>
   <td><?php echo $pilot->firstname.' '.$pilot->lastname ?>
    </td>
  </tr>
  <?php

}

?>
 </tbody>
</table>

</div>
</div>

exactly like that, into frontpage_recentpilots.tpl

Then

 <?php MainController::Run('Pilots', 'RecentFrontPage', 5); ?>

wherever you want it...

Should only show 5... if not you did it wrong :S

Link to comment
Share on other sites

Yep. That worked. Like I said, I edited the wrong files. I had so many different things going on in here I confused my self somehow.

Got it all squared away and was getting ready to post I got it fixed. You beat me to it.

Thanks for the help today Tom. I appreciate it. Works a treat now.

Link to comment
Share on other sites

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