Thomas Rozanov Posted March 15, 2011 Report Share Posted March 15, 2011 Okay, So I use jantorre (thanks!) custom charts database code which is: <h3>Procedures and Information</h3> <table width="98%" align="center"> <tr style="background-color: #333; color: #FFF;"> <td>Charts for <?php echo $schedule->depicao?></td> <td>Charts for <?php echo $schedule->arricao?></td> </tr> <tr align="center"> <td width="50%" valign="top"> <a href="<?php $data = OperationsData::GetAirportInfo($schedule->depicao); echo $data->chartlink; ?>" target="_blank"> <img border="0" src="http://www.yoursite.com/images/charts/<?php echo $schedule->depicao?>.gif" width="387px" height="594px" alt="No chart available" /></a><br> <a href="<?php $data = OperationsData::GetAirportInfo($schedule->depicao); echo $data->vacc; ?>" target="_blank">Local VACC</a> </td> <td width="50%" valign="top"> <a href="<?php $data = OperationsData::GetAirportInfo($schedule->arricao); echo $data->chartlink; ?>" target="_blank"> <img border="0" src="http://www.yoursite.com/images/charts/<?php echo $schedule->arricao?>.gif" width="387px" height="594px" alt="No chart available" /></a><br> <a href="<?php $data = OperationsData::GetAirportInfo($schedule->arricao); echo $data->vacc; ?>" target="_blank">Local VACC</a> </td> </tr> </table> And everything works great but i need it to work for both .png and .gif . So Lorathon (Big Thanks!) wrote a small piece of code to help me out. public function displayChart($icao) { $chart = SITE_ROOT.'/images/charts/'.$icao.'.png'; if(!file_exists($chart)) { // PNG image Does NOT exist so look for GIF image $chart = SITE_ROOT.'/images/charts/'.$icao.'.gif'; if(!file_exists($chart)) { // GIF image does not exist either return false; } } // Return image path return $chart; } And suggested to insert it like so in schdule_brief.tpl <h3>Procedures and Information</h3> <table width="98%" align="center"> <tr style="background-color: #333; color: #FFF;"> <td>Charts for <?php echo $schedule->depicao?></td> <td>Charts for <?php echo $schedule->arricao?></td> </tr> <tr align="center"> <td width="50%" valign="top"> <a href="<?php $data = OperationsData::GetAirportInfo($schedule->depicao); echo $data->chartlink; ?>" target="_blank"> <img border="0" src="<?php echo self::displayChart($schedule->depicao)?>" width="387px" height="594px" alt="No chart available" /></a><br> <a href="<?php $data = OperationsData::GetAirportInfo($schedule->depicao); echo $data->vacc; ?>" target="_blank">Local VACC</a> </td> <td width="50%" valign="top"> <a href="<?php $data = OperationsData::GetAirportInfo($schedule->arricao); echo $data->chartlink; ?>" target="_blank"> <img border="0" src="<?php echo self::displayChart($schedule->arricao)?>" width="387px" height="594px" alt="No chart available" /></a><br> <a href="<?php $data = OperationsData::GetAirportInfo($schedule->arricao); echo $data->vacc; ?>" target="_blank">Local VACC</a> </td> </tr> </table> <?php public function displayChart($icao) { $chart = SITE_ROOT.'/images/charts/'.$icao.'.png'; if(!file_exists($chart)) { // PNG image Does NOT exist so look for GIF image $chart = SITE_ROOT.'/images/charts/'.$icao.'.gif'; if(!file_exists($chart)) { // GIF image does not exist either return false; } } // Return image path return $chart; } ?> And I'm getting : Parse error: syntax error, unexpected T_PUBLIC in /home/brtvirtu/public_html/lib/skins/ObsessBlue/schedule_briefing.tpl on line 140 And line 140 is public function displayChart($icao) Please Help! Or suggest something else Thanks! Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 15, 2011 Report Share Posted March 15, 2011 Sorry I did not get back to you right away with your PM. Remove the word "public" and see how it works. Quote Link to comment Share on other sites More sharing options...
Thomas Rozanov Posted March 15, 2011 Author Report Share Posted March 15, 2011 Sorry I did not get back to you right away with your PM. Remove the word "public" and see how it works. Okay now it works (kind of) except the page is totally deformated and in the charts part it says : Fatal error: Call to undefined method TemplateSet::displayChart() in /home/brtvirtu/public_html/lib/skins/ObsessBlue/schedule_briefing.tpl on line 125 line 125 is : <img border="0" src="<?php echo self::displayChart($schedule->depicao)?>" Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 15, 2011 Report Share Posted March 15, 2011 Like I said in my PM's, I think you are going to have to write a class. Then stick the code I wrote in there. Then call the function from that class. Look in the core/common for the class files. See how they work and try and figure it out. OR Like was initially suggested, do the easy thing and change all the files to the same type Quote Link to comment Share on other sites More sharing options...
Thomas Rozanov Posted March 15, 2011 Author Report Share Posted March 15, 2011 Like I said in my PM's, I think you are going to have to write a class. Then stick the code I wrote in there. Then call the function from that class. Look in the core/common for the class files. See how they work and try and figure it out. OR Like was initially suggested, do the easy thing and change all the files to the same type Wait so i put your code into a seperate .php or .tpl file and i just put include file. In the schedule_brief.tpl Quote Link to comment Share on other sites More sharing options...
Thomas Rozanov Posted March 15, 2011 Author Report Share Posted March 15, 2011 Somebody please help me out here. What do you suggest... Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted March 23, 2011 Moderators Report Share Posted March 23, 2011 HI, I can give you the code that i use but its the picture in the briefing page is for one file type only ie .png and when you click you get the chart to download if thats any good to you? 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.