Jump to content

Recommended Posts

Posted

Hey everyone,

I'm trying to put phpVMS into a template I like, and when I use the code from frontpage_recentpilots.tpl to show the most recent pilots on the front page, it gives me this error:

Warning: Invalid argument supplied for foreach() in /home/airtranv/public_html/lib/skins/AirTran/layout.tpl on line 223

Here is the code that I used which resulted in that error


<?php

foreach($pilots as $pilot)
{
?>
<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
}
?>

  • Moderators
Posted

Use this instead:

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

This will show you the last 5 pilots and you can change the "5" to your desired number.

  • Like 1
  • Moderators
Posted

You just only needed to add the $pilots function.

Example...

<?php
$count = 5;
$pilots = PilotData::GetLatestPilots($count);
foreach($pilots as $pilot)
{
?>
<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
}
?>

  • Like 1
  • Moderators
Posted

Marking Solved

next time whenever you find a solution, be sure to edit your first post and add SOLVED to the title.

Cheers!

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