AGuyFawkesMask Posted December 9, 2012 Report Share Posted December 9, 2012 Good evening, everyone--and happy holidays! I'm unsure whether or not this is the appropriate section to ask whether or not anyone developed a solution for this yet, but I'm not exactly asking for support. This is just a question. Has anyone ever written a script that excludes certain airports from showing up in the depapttab, arrapttab dropdown menus on their schedules_searchform.tpl? This would be useful to me because I have certain airports right now in my phpvms_airports table that were previously used during temporary "charter" activities. Today, we no longer utilize them in our day-to-day operation. Here's what I originally came up with: <div id="depapttab"> <p>Select your departure airport:</p> <select id="depicao" name="depicao"> <option value="">Select All</option> <?php $exclude = array(13, 18, 19, 22); if(!$depairports) $depairports = array(); foreach($depairports as $airport) { if(!in_array($depairports->id, $exclude)) { echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>'; } } ?> </select> <input type="submit" name="submit" value="Find Flights" /> </div> Unfortunately, none of this worked though. Any insight? I have a feeling it might be connected to modules/Schedules.php, but I'm unsure. Thanks in advance for the assistance. Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted December 9, 2012 Moderators Report Share Posted December 9, 2012 if you think you won't use those airports ever again, then you'll have to do two things to remove them for good: 1. Delete the airports from your DB totally. 2. Delete all schedules you have created for those airports * You can either use the admin center for this or your DB. But if you want them to be there just in case for future use then you're gonna have to write some code and say if $airport->name == "LLLL", continue here is an example: foreach($depairports as $airport) { { if($airport->icao == "ABCD") { continue; } echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>'; } Now "ABCD" is the ICAO of the airport you want to exclude. 1 Quote Link to comment Share on other sites More sharing options...
AGuyFawkesMask Posted December 9, 2012 Author Report Share Posted December 9, 2012 That's a good idea, parkho, but I actually solved the issue myself! Have a look: <div id="depapttab"> <p>Select your departure airport:</p> <select id="depicao" name="depicao"> <option value="">Select All</option> <?php $exclude = array(13, 18, 19, 22); // Airport IDs found in phpVMS_airports not to be included in the dropdown menu if(!$depairports) $depairports = array(); foreach($depairports as $airport) { if(!in_array($airport->id, $exclude)) { // Exclude values in the above array from the dropdown menu echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>'; } } ?> </select> <input type="submit" name="submit" value="Find Flights" /> </div> It was really just a small error that I failed to catch. I was using... if(!in_array($depairports->id, $exclude)) ...instead of... if(!in_array($airport->id, $exclude)) What a silly mistake! Anyway, all fixed now. Hopefully this can be of benefit to some other users. (I think I tagged the right search words.) Thanks for the suggestion, though. And have a good holiday! Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted December 9, 2012 Moderators Report Share Posted December 9, 2012 yep! That's another way. You can add this to code snippets section if you want. 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.