Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 12388
Latest: Rands
New This Month: 5
New This Week: 0
New Today: 0
Stats
Total Posts: 40310
Total Topics: 7100
Most Online Today: 97
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 33
Total: 33

Author Topic: Random Downloads Block  (Read 17631 times)

0 Members and 1 Guest are viewing this topic.

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Random Downloads Block
« on: June 25, 2012, 01:57:43 am »
Hi was wondering if it was possible to have a random downloads block for tiny portal showing maybe showing 4 or 5 random downloads


Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Random Downloads Block
« Reply #1 on: June 25, 2012, 11:48:07 am »
I could write some code for it I think I did it for ezPortal what information do you want to display.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Random Downloads Block
« Reply #2 on: June 27, 2012, 02:30:13 am »
Hi that would be great I would like it to show select possibly 5 random books displaying the thumbnail and download title

many thanks again

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Random Downloads Block
« Reply #3 on: June 27, 2012, 11:31:02 am »
Last question forgot to ask what SMF version are you using?
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Random Downloads Block
« Reply #4 on: June 27, 2012, 12:38:17 pm »
SMF 2.0.2

thanks

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Random Downloads Block
« Reply #5 on: June 27, 2012, 02:15:03 pm »
Try this
Code: [Select]

global $modSettings, $smcFunc, $boardurl, $txt, $scripturl;

$isPro = true;
        $files = 5;
        $maxrowlevel = 5;

// 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 https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Random Downloads Block
« Reply #6 on: June 27, 2012, 04:51:03 pm »
doesn't work just adds my whole front page into the block

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Random Downloads Block
« Reply #7 on: June 27, 2012, 04:55:45 pm »
Link to the block/issue?
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Random Downloads Block
« Reply #8 on: June 28, 2012, 04:41:16 am »
Hi I have attached 2 screenshots 1 with the code 1 without the code


Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Random Downloads Block
« Reply #9 on: June 28, 2012, 10:13:29 am »
Any errors in the forum error log?
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Random Downloads Block
« Reply #10 on: June 29, 2012, 01:47:10 am »
Undefined index: ezp_pagemanager

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Random Downloads Block
« Reply #11 on: June 29, 2012, 09:38:56 am »
That wouldn't be it that's from a portal system.


Not sure what is causing the whole page to load in that box.

For the code make sure you are using a php code block in your portal settings.


If you are using ezPortal there is a downloads block built in.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Random Downloads Block
« Reply #12 on: June 29, 2012, 11:13:07 pm »
not sure if this matters as I know next to nothing about the code but would the fact I have removed the information and log in section at the top of the main page matter, someone from the SMF forums altered my index.template file to enable this

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Random Downloads Block
« Reply #13 on: July 01, 2012, 06:18:15 pm »
How are you inserting the code?
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shaka

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Random Downloads Block
« Reply #14 on: July 01, 2012, 11:12:59 pm »
tiny portal PHP block with frame style from theme selected

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
4050 Views
Last post February 18, 2008, 08:03:27 am
by Ken.
4 Replies
3537 Views
Last post June 18, 2010, 09:18:00 am
by dvera
2 Replies
2689 Views
Last post November 01, 2010, 01:32:28 pm
by clothahump
1 Replies
2653 Views
Last post October 16, 2016, 12:12:51 pm
by exit
5 Replies
2950 Views
Last post July 12, 2017, 03:45:34 pm
by donk

+- Recent Topics

Quality of images after import by SMFHacks
September 05, 2020, 10:21:44 am

How do I download gallery images? by CWVRV
August 30, 2020, 11:50:07 pm

Deleting Empty Galleries by SMFHacks
August 30, 2020, 11:43:32 am

PHP error by davejo
August 25, 2020, 07:35:13 am

Permissions to list ads and buy items by CWVRV
August 21, 2020, 05:19:45 pm

Doubt with download permissions. by Rock Lee
August 20, 2020, 08:23:24 pm

Attachment images Upsidedown or Sideways by SMFHacks
August 18, 2020, 05:41:07 pm

[Mod]Avatars Display Integration by Hatshepsut
August 17, 2020, 11:39:54 pm

Simple Portal Block - Classifieds by SMFHacks
August 16, 2020, 09:56:48 am

SMF Links by SMFHacks
August 16, 2020, 08:03:42 am

Powered by EzPortal