Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 11970
Latest: ch4rity10
New This Month: 14
New This Week: 4
New Today: 0
Stats
Total Posts: 38048
Total Topics: 6696
Most Online Today: 93
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 54
Total: 54

Author Topic: Latest Downloads Block for Tiny Portal  (Read 3864 times)

0 Members and 1 Guest are viewing this topic.

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Latest Downloads Block for Tiny Portal
« on: January 21, 2012, 08:52:18 pm »
Hi guys sorry if this is already done but I have searched and cannot find it

I am looking for a code to add a latest downloads block for tiny portal

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 14096
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #1 on: January 21, 2012, 08:53:48 pm »
What do you want to show? A listing of latest downloads? And how do you want it to be formatted?
Get your Forum Ranked! at http://www.forumrankings.net - find out how your forum compares with others! Also contests/promotions for verified sites.

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #2 on: January 21, 2012, 09:02:30 pm »
Yes much like the layout on the downloads page showing the title and image but would like to put it in a block and display it on my index page  e.g Latest 50 downloads added

hope I am explaining this ok  ???

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 14096
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #3 on: January 21, 2012, 11:16:08 pm »
Now is the download image a screenshot or a download link?
Vertical like this?

Title
Download Image

Title
Download Image
Get your Forum Ranked! at http://www.forumrankings.net - find out how your forum compares with others! Also contests/promotions for verified sites.

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #4 on: January 22, 2012, 03:59:42 am »
A screenshot would be great with maybe a link either from the image or title to the download page of that download

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 14096
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #5 on: January 23, 2012, 07:43:32 pm »
One more thing I need what SMF version then will write a quick code.
Get your Forum Ranked! at http://www.forumrankings.net - find out how your forum compares with others! Also contests/promotions for verified sites.

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #6 on: January 24, 2012, 02:37:47 am »
Running the latest version 2.0.2  many thanks

before you go ahead and if possible I am only looking for the preview image, title and uploader info to be displayed, just if possible but I will be grateful whatever you can come up with

thanks

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 14096
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #7 on: January 24, 2012, 06:16:07 pm »
Try this code adapted from ezPortal

Code: [Select]

//Example call
DownloadsBlock(1,4,'recent');

function DownloadsBlock($rows = 4, $files = 4, $type = 'recent')
{
global $txt, $smcFunc, $scripturl,  $modSettings, $scripturl, $boardurl;

$rows = (int) $rows;
$files = (int) $files;



$isPro = true;


// Load the language files
if (loadlanguage('Downloads') == false)
loadLanguage('Downloads','english');


if (empty($modSettings['down_url']))
$modSettings['down_url'] = $boardurl . '/downloads/';

$maxrowlevel = $rows;
echo '<table cellspacing="0" cellpadding="5" border="0" align="center" width="100%">
';
//Check what type it is
$selectPro = '';
$selectProJoin = '';
if ($isPro == true)
{
$selectPro = " f.ID_PICTURE, f.thumbfilename, ";
$selectProJoin =  " LEFT JOIN {db_prefix}down_file_pic AS f ON (f.ID_PICTURE = p.ID_PICTURE) ";
}

$query = ' ';
switch($type)
{
case 'recent':
$query = "SELECT p.ID_FILE, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE  p.approved = 1 ORDER BY p.ID_FILE DESC LIMIT $files";
break;

case 'viewed':
$query = "SELECT p.ID_FILE, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE p.approved = 1 ORDER BY  p.views DESC LIMIT $files";
break;

case 'mostcomments':
$query = "SELECT p.ID_FILE, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE p.approved = 1 ORDER BY p.commenttotal DESC LIMIT $files";
break;

case 'toprated':
$query = "SELECT p.ID_FILE,  (p.rating / p.totalratings ) AS ratingaverage, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE p.approved = 1 ORDER BY ratingaverage DESC LIMIT $files ";
break;

case 'downloads':
$query = "SELECT p.ID_FILE, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE p.approved = 1 ORDER BY  p.totaldownloads DESC LIMIT $files";
break;
}
// Execute the SQL query
$dbresult = $smcFunc['db_query']('', $query);
$rowlevel = 0;
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
if ($rowlevel == 0)
echo '<tr class="windowbg2">';

echo '<td align="center"><a href="' . $scripturl . '?action=downloads;sa=view;id=' . $row['ID_FILE'] . '">',$row['title'],'</a><br />';

if ($isPro == true && $modSettings['down_set_t_image'] && !empty($row['thumbfilename']))
echo '<a href="' . $scripturl . '?action=downloads;sa=view;id=' . $row['ID_FILE'] . '"><img src="',$modSettings['down_url'],$row['thumbfilename'],'" alt="" /></a><br />';


echo '<span class="smalltext">';
//if (!empty($modSettings['down_set_t_rating']))
//echo $txt['downloads_form_rating'] . EzGetStarsByPrecent(($row['totalratings'] != 0) ? ($row['rating'] / ($row['totalratings']* 5) * 100) : 0) . '<br />';

if (!empty($modSettings['down_set_t_downloads']))
echo $txt['downloads_text_downloads'] . $row['totaldownloads'] . '<br />';
if (!empty($modSettings['down_set_t_views']))
echo $txt['downloads_text_views'] . $row['views'] . '<br />';
if (!empty($modSettings['down_set_t_filesize']))
echo $txt['downloads_text_filesize'] . round($row['filesize'] / 1024, 2) . 'KB<br />';
if (!empty($modSettings['down_set_t_date']))
echo $txt['downloads_text_date'] . timeformat($row['date']) . '<br />';
if (!empty($modSettings['down_set_t_comment']))
echo $txt['downloads_text_comments'] . ' (<a href="' . $scripturl . '?action=downloads;sa=view;id=' . $row['ID_FILE'] . '">' . $row['commenttotal'] . '</a>)<br />';
if (!empty($modSettings['down_set_t_username']))
{
if ($row['real_name'] != '')
echo $txt['downloads_text_by'] . ' <a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">'  . $row['real_name'] . '</a><br />';
else
echo $txt['downloads_text_by'] . ' ' . $txt['downloads_guest'] . '<br />';
}
echo '</span></td>';


if ($rowlevel < ($maxrowlevel-1))
$rowlevel++;
else
{
echo '</tr>';
$rowlevel = 0;
}
}
if ($rowlevel !=0)
{
echo '</tr>';
}

echo '
      </table><br />';


}
Get your Forum Ranked! at http://www.forumrankings.net - find out how your forum compares with others! Also contests/promotions for verified sites.

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #8 on: January 24, 2012, 06:40:53 pm »
wow almost perfect

is it possible only to show the image, title and members name

can I alter how many it shows i.e. latest 50 downloads

as it is for a center block is it possible to have them horizontal and vertical say 4 across and 12 down

thanks so much for taking the time  ;)

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 14096
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #9 on: January 24, 2012, 06:46:25 pm »
Retry this code
Code: [Select]
//Example call
DownloadsBlock(4,50,'recent');

function DownloadsBlock($rows = 4, $files = 4, $type = 'recent')
{
global $txt, $smcFunc, $scripturl,  $modSettings, $scripturl, $boardurl;

$rows = (int) $rows;
$files = (int) $files;



$isPro = true;


// Load the language files
if (loadlanguage('Downloads') == false)
loadLanguage('Downloads','english');


if (empty($modSettings['down_url']))
$modSettings['down_url'] = $boardurl . '/downloads/';

$maxrowlevel = $rows;
echo '<table cellspacing="0" cellpadding="5" border="0" align="center" width="100%">
';
//Check what type it is
$selectPro = '';
$selectProJoin = '';
if ($isPro == true)
{
$selectPro = " f.ID_PICTURE, f.thumbfilename, ";
$selectProJoin =  " LEFT JOIN {db_prefix}down_file_pic AS f ON (f.ID_PICTURE = p.ID_PICTURE) ";
}

$query = ' ';
switch($type)
{
case 'recent':
$query = "SELECT p.ID_FILE, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE  p.approved = 1 ORDER BY p.ID_FILE DESC LIMIT $files";
break;

case 'viewed':
$query = "SELECT p.ID_FILE, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE p.approved = 1 ORDER BY  p.views DESC LIMIT $files";
break;

case 'mostcomments':
$query = "SELECT p.ID_FILE, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE p.approved = 1 ORDER BY p.commenttotal DESC LIMIT $files";
break;

case 'toprated':
$query = "SELECT p.ID_FILE,  (p.rating / p.totalratings ) AS ratingaverage, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE p.approved = 1 ORDER BY ratingaverage DESC LIMIT $files ";
break;

case 'downloads':
$query = "SELECT p.ID_FILE, p.commenttotal, $selectPro p.totalratings, p.rating, p.filesize, p.views, p.title, p.ID_MEMBER, m.real_name, p.date, p.description, p.totaldownloads
FROM {db_prefix}down_file as p
LEFT JOIN {db_prefix}members AS m  ON (m.ID_MEMBER = p.ID_MEMBER)
$selectProJoin
WHERE p.approved = 1 ORDER BY  p.totaldownloads DESC LIMIT $files";
break;
}
// Execute the SQL query
$dbresult = $smcFunc['db_query']('', $query);
$rowlevel = 0;
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
if ($rowlevel == 0)
echo '<tr class="windowbg2">';

echo '<td align="center"><a href="' . $scripturl . '?action=downloads;sa=view;id=' . $row['ID_FILE'] . '">',$row['title'],'</a><br />';

if ($isPro == true && $modSettings['down_set_t_image'] && !empty($row['thumbfilename']))
echo '<a href="' . $scripturl . '?action=downloads;sa=view;id=' . $row['ID_FILE'] . '"><img src="',$modSettings['down_url'],$row['thumbfilename'],'" alt="" /></a><br />';


echo '<span class="smalltext">';
//if (!empty($modSettings['down_set_t_rating']))
//echo $txt['downloads_form_rating'] . EzGetStarsByPrecent(($row['totalratings'] != 0) ? ($row['rating'] / ($row['totalratings']* 5) * 100) : 0) . '<br />';



if (!empty($modSettings['down_set_t_username']))
{
if ($row['real_name'] != '')
echo $txt['downloads_text_by'] . ' <a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">'  . $row['real_name'] . '</a><br />';
else
echo $txt['downloads_text_by'] . ' ' . $txt['downloads_guest'] . '<br />';
}
echo '</span></td>';


if ($rowlevel < ($maxrowlevel-1))
$rowlevel++;
else
{
echo '</tr>';
$rowlevel = 0;
}
}
if ($rowlevel !=0)
{
echo '</tr>';
}

echo '
      </table><br />';


}
Get your Forum Ranked! at http://www.forumrankings.net - find out how your forum compares with others! Also contests/promotions for verified sites.

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Latest Downloads Block for Tiny Portal
« Reply #10 on: January 24, 2012, 06:49:25 pm »
wow that is perfect, thank you so much  :)

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
5014 Views
Last post October 30, 2007, 08:03:03 am
by SMFHacks
5 Replies
6408 Views
Last post May 12, 2008, 02:28:21 pm
by briankstan
0 Replies
2022 Views
Last post May 13, 2009, 03:18:58 pm
by propyl
1 Replies
2441 Views
Last post August 23, 2009, 07:31:56 pm
by SMFHacks
2 Replies
4192 Views
Last post April 01, 2010, 07:39:09 am
by Pegasys

+- Recent Topics

Nochex by SMFHacks
July 19, 2017, 02:57:10 pm

using Simple Audio Video Embedder and would like to order a custom code by Beowulf1976
July 12, 2017, 11:44:20 pm

Random Image Block code by donk
July 12, 2017, 03:45:34 pm

Enotify Copyright Removal Problem by Niteprowler
July 11, 2017, 09:18:39 am

NEW TAB ON CHECKOUT by orville
July 10, 2017, 11:29:27 am

errors after installation by donk
July 09, 2017, 04:00:34 am

Images Uploading, but Not Displaying by SMFHacks
July 06, 2017, 05:02:31 pm

Question aboud SA Facebook Integration by SMFHacks
July 05, 2017, 09:46:41 pm

Problem Saving Pics by SMFHacks
July 04, 2017, 11:14:07 am

Adding news topic by RC Storick
July 01, 2017, 10:49:07 am

Powered by EzPortal