SMFHacks.com
SMFHacks
Community Suite
SMF Gallery Pro
SMF Store
SMF Classifieds
Newsletter Pro
Downloads System Pro
Ad Seller Pro
Badge Awards
Hacks and Mods
Latest SMF Hacks
TopTen Hacks
Styles and Themes
Add a Hack
Manage Hacks
Earn Money from Your Forum with these tips
SMF Theme Generator
SMF Package Parser
Free SMF Hosting
Buy Website Traffic
Site Showcase
Email Marketing Software
Search Forums
Advanced search
User
Welcome,
Guest
. Please
login
or
register
.
May 18, 2013, 07:51:20 am
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Stats
Members
Total Members: 10755
Latest:
henrywilliams0173
Stats
Total Posts: 32348
Total Topics: 5473
Online Today: 50
Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Users: 0
Guests: 36
Total: 36
SMFHacks.com
Forum
Downloads System Pro
Support
Latest Downloads Block for Tiny Portal
0 Members and 1 Guest are viewing this topic.
« previous
next »
Pages:
[
1
]
Author
Topic: Latest Downloads Block for Tiny Portal (Read 1269 times)
shaka
Inline PM Customer
Offline
Posts: 37
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
Logged
SMFHacks
Administrator
Hero Member
Offline
Posts: 10987
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?
Logged
shaka
Inline PM Customer
Offline
Posts: 37
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
Logged
SMFHacks
Administrator
Hero Member
Offline
Posts: 10987
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
Logged
shaka
Inline PM Customer
Offline
Posts: 37
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
Logged
SMFHacks
Administrator
Hero Member
Offline
Posts: 10987
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.
Logged
shaka
Inline PM Customer
Offline
Posts: 37
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
Logged
SMFHacks
Administrator
Hero Member
Offline
Posts: 10987
Re: Latest Downloads Block for Tiny Portal
«
Reply #7 on:
January 24, 2012, 06:16:07 pm »
Try this code adapted from ezPortal
Code:
//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 />';
}
Logged
shaka
Inline PM Customer
Offline
Posts: 37
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
Logged
SMFHacks
Administrator
Hero Member
Offline
Posts: 10987
Re: Latest Downloads Block for Tiny Portal
«
Reply #9 on:
January 24, 2012, 06:46:25 pm »
Retry this code
Code:
//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 />';
}
Logged
shaka
Inline PM Customer
Offline
Posts: 37
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
Logged
Pages:
[
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
SMFHacks.com
-----------------------------
=> News
=> Site Discussion
===> Suggestions
===> Bugs
-----------------------------
SMF Gallery Pro
-----------------------------
=> Announcements
=> Presales
=> Support
===> Bugs
===> Feature Requests
-----------------------------
SMF Store
-----------------------------
=> Announcements
=> Presales
=> Support
===> Guides and Tips
===> Feature Requests
===> Bugs
-----------------------------
SMF Classifieds
-----------------------------
=> Announcements
=> Presales
=> Support
===> Bugs
===> Feature Requests
-----------------------------
Downloads System Pro
-----------------------------
=> Announcements
=> Presales
=> Support
===> Feature Requests
===> Bugs
-----------------------------
Ad Seller Pro
-----------------------------
=> Presales
=> Support
-----------------------------
Menu Editor Pro
-----------------------------
=> Presales Menu Editor Pro
=> Bug Reports
-----------------------------
Inline Personal Messages
-----------------------------
=> Presales
=> Support
=> Bug Reports
-----------------------------
Newsletter Pro
-----------------------------
=> Presales
=> Support
===> Feature Requests
-----------------------------
Badge Awards
-----------------------------
=> Presales
=> Support
-----------------------------
Tweet Topics/FB Post System
-----------------------------
=> Presales
-----------------------------
Social Login Pro
-----------------------------
=> Presales
-----------------------------
SMF Gallery Lite
-----------------------------
=> SMF Gallery Lite
-----------------------------
Modifications/Themes
-----------------------------
=> General SMF Forum
=> Modifications Talk
===> Latest Mods
===> Modification Showcase
=> Theme Talk
===> Theme Showcase
===> Latest Themes
Recent
Feature Requests for SMF ...
by
Secure
[May 16, 2013, 10:13:46 pm]
stuck on "Processing" scr...
by
SMFHacks
[May 15, 2013, 11:32:14 pm]
[Request] - Award for any...
by
SMFHacks
[May 15, 2013, 11:31:24 pm]
SMF Gallery Pro 5.0.1 not...
by
SMFHacks
[May 12, 2013, 09:10:43 am]
Golf Theme
by
Serglike
[May 10, 2013, 03:49:55 am]
Display ads on every page...
by
SMFHacks
[May 07, 2013, 07:12:40 pm]
Edited simple ad code and...
by
ApplianceJunk
[May 07, 2013, 02:37:14 pm]
"non" error on bulk uploa...
by
SMFHacks
[May 06, 2013, 10:29:56 pm]
Can I give member an ad p...
by
fernowl
[May 04, 2013, 03:22:01 pm]
How to configure the Auto...
by
SMFHacks
[May 04, 2013, 01:08:57 pm]
Random Picture
Donate to SMFHacks.com
Help Support the SMFHacks.com mod making.
Loading...