Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 11288
Latest: rrwe
New This Month: 45
New This Week: 12
New Today: 1
Stats
Total Posts: 33974
Total Topics: 6053
Most Online Today: 119
Most Online Ever: 2482
(April 09, 2011, 06:02:45 pm)
Users Online
Members: 1
Guests: 85
Total: 86

Author Topic: Latest Downloads Block for Tiny Portal  (Read 2059 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: 12427
    • 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: 12427
    • 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: 12427
    • 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: 12427
    • 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: 12427
    • 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  :)

 

+- Recent Topics

will work on SMF 2.1? by SMFHacks
November 26, 2014, 04:19:21 pm

Upgraded forum to SMF2.0 - Problems by amwebby
November 26, 2014, 10:43:01 am

Uploading GIF with animation loses animation by SMFHacks
November 26, 2014, 01:22:53 am

question by SMFHacks
November 25, 2014, 03:42:13 pm

help with index template for custom theme on add seller pro community suite by apache
November 25, 2014, 11:18:37 am

ad seller pro execute modification test failed by SMFHacks
November 25, 2014, 08:40:06 am

Adding check all to display.template.php by shuban
November 24, 2014, 09:32:17 pm

Tapatalk... by SMFHacks
November 24, 2014, 10:33:56 am

Combining Board Index Top and Overall Header by SMFHacks
November 24, 2014, 10:16:26 am

Do I have to install each mod if I bought the community suite by SMFHacks
November 24, 2014, 09:53:24 am

Powered by EzPortal