PilotJordan Posted July 16, 2012 Report Posted July 16, 2012 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 } ?> Quote
Moderators Parkho Posted July 16, 2012 Moderators Report Posted July 16, 2012 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. 1 Quote
Moderators Kyle Posted July 16, 2012 Moderators Report Posted July 16, 2012 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 } ?> 1 Quote
PilotJordan Posted July 16, 2012 Author Report Posted July 16, 2012 Thanks guys! Very much appreciated. Quote
Moderators Kyle Posted July 16, 2012 Moderators Report Posted July 16, 2012 Marking Solved next time whenever you find a solution, be sure to edit your first post and add SOLVED to the title. Cheers! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.