TAV1702 Posted April 7, 2011 Report Share Posted April 7, 2011 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. Quote Link to comment Share on other sites More sharing options...
Tom Posted April 7, 2011 Report Share Posted April 7, 2011 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> Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 7, 2011 Author Report Share Posted April 7, 2011 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. 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. Quote Link to comment Share on other sites More sharing options...
Tom Posted April 7, 2011 Report Share Posted April 7, 2011 Why don't you just use the original frontpage recent pilots and edit frontpage_recentpilots.tpl to suit? Makes life easier. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 7, 2011 Author Report Share Posted April 7, 2011 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. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 7, 2011 Author Report Share Posted April 7, 2011 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 } ?> Quote Link to comment Share on other sites More sharing options...
Tom Posted April 7, 2011 Report Share Posted April 7, 2011 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) Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 7, 2011 Author Report Share Posted April 7, 2011 DOH!!!!!!! Now I got ya. Lordy lordy. I look way to far in to things don't I tom? I totally got you now. Thanks. I really appreciate it. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 7, 2011 Author Report Share Posted April 7, 2011 Well that actually narrowed down the pilots to 5. BUT it got rid of the table in the process. Quote Link to comment Share on other sites More sharing options...
Tom Posted April 7, 2011 Report Share Posted April 7, 2011 Did you put your table into frontpage_recentpilots.tpl? You have to do that too. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 7, 2011 Author Report Share Posted April 7, 2011 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? Quote Link to comment Share on other sites More sharing options...
Tom Posted April 7, 2011 Report Share Posted April 7, 2011 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 Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 7, 2011 Author Report Share Posted April 7, 2011 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. Quote Link to comment Share on other sites More sharing options...
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.