Jump to content

Recent Download Uploaded


jamyboy

Recommended Posts

hey guys i was hoping if someone can help me to show my recent downloads uploaded on the main page or on pilot profile would be great because sometimes when we update the download section or upload a new Acars version or Aircrafts people still be asking so i think it would be great idea to show recent uploaded download would be easier for pilots to know?

Help would be really appreciated.

Thanks

James

Link to comment
Share on other sites

yea jeff you are right but i was thinking to put this on main page would be very easy for me and for pilots it will save lot of time to write about the latest updates in forums in detail thanks any ways.

any further idea and help please to make this possible like we can show our recent reports bids so i think it would be possible also but i need help how can i fetch data and what would be the code i shall wait for further replies.

good day james

Link to comment
Share on other sites

  • Administrators

You could add something like this to a custom data class;

<?php
 function get_latest_downloads()
   {
       $sql = "SELECT * FROM ".TABLE_PREFIX."downloads
               ORDER BY id DESC LIMIT 5";
       return DB::get_results($sql);
   }
?>

That would give you the last 5 downloads in order of their database id. You can loop through the results using a foreach command.

Link to comment
Share on other sites

first of all thank you so much simpilot for helping out but let me say that i am nob in PHP thing instead of making it right i will mess up with files so will request you if you can tell me in very simple version where to put the above code in which data class file and what code should i use on front page or pilot center to fetch the data i would highly appreciate your effort of explaining please.

i shall wait for your reply

thanks and best regards

James

Link to comment
Share on other sites

ok simpilot i have tried by my self taken a reference codes from front_recentbids and more and tried to get the result but failed here what i do.

i have added your given code in DownloadData.class.php like this

public static function get_latest_downloads()
   {
       $sql = "SELECT * FROM ".TABLE_PREFIX."downloads
               ORDER BY id DESC LIMIT 5";
       return DB::get_results($sql);
   }

}

than after looking the recentbids code i have created a module file with the name FrontDownloads.php and added this code in it.

<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
*	Forums: http://www.phpvms.net/forum
*	Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
*   Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
*   View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

class FrontDownloads extends CodonModule
{

public function index()
{
	$this->RecentFrontPage();
}

   public function RecentFrontPage($total=5)
{

	$this->set('lastdownloads', DownloadData::GetLatestDownloads($total));
	$this->render('frontpage_recentdownloads.tpl');
}
}

after that created front_recentdownloads.tpl file and given this code to show on front page.

<?php
if(!$downloads)
{
echo 'No downloads have been uploaded';
return;
}

foreach($downloads as $download)
{
?>
<table class="tablesorter" width="100%" cellpadding="0" cellspacing="0" bordercolor="#0B3861">
<tr>
<td width="40%" style="color: #FFF; background-color:#3584BD;"><div align="left"><?php echo $download->name?>
 </div></td>
<td width="31%" style="color: #FFF; background-color:#3584BD;"><div align="left"><?php echo $download->description?>
 </div></td>
 <td width="31%" style="color: #FFF; background-color:#3584BD;"><div align="left"><?php echo $download->link?>
 </div></td>
 <td width="31%" style="color: #FFF; background-color:#3584BD;"><div align="left"><?php echo $download->image?>
 </div></td>
</tr>
<?php
}
?>
</table>

when checked on the main page got error

Fatal error: Call to undefined method DownloadData::GetLatestDownloads() in C:\wamp\www\RVA\core\modules\FrontDownloads\FrontDownloads.php on line 30

i tried now its your turn to show me a way please.

james

Link to comment
Share on other sites

  • Administrators

Check your function call - you are aksing for;

DownloadData::GetLatestDownloads($total)

and getting the error

Fatal error: Call to undefined method DownloadData::GetLatestDownloads() in C:\wamp\www\PIA\core\modules\FrontDownloads\FrontDownloads.php on line 30

the new function is called

get_latest_downloads()

Link to comment
Share on other sites

thanks for guiding sir fatal error have been gone now by simply putting your command and now its not showing anything on front page just tell me is this code ok to fetch data from database or not if not than just please tell me how to put this code in front_recentdownloads.tpl file

<?php
if(!$downloads)
{
echo 'No New Uploads';
return;
}

foreach($downloads as $download)
{
?>
<table class="tablesorter" width="100%" cellpadding="0" cellspacing="0" bordercolor="#0B3861">
<tr>
<td width="40%" style="color: #FFF; background-color:#3584BD;"><div align="left"><?php echo $download->name?>
 </div></td>
<td width="31%" style="color: #FFF; background-color:#3584BD;"><div align="left"><?php echo $download->description?>
 </div></td>
 <td width="31%" style="color: #FFF; background-color:#3584BD;"><div align="left"><?php echo $download->link?>
 </div></td>
 <td width="31%" style="color: #FFF; background-color:#3584BD;"><div align="left"><?php echo $download->image?>
 </div></td>
</tr>
<?php
}
?>
</table>

Link to comment
Share on other sites

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