Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 201
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 195
Total: 195

Author Topic: Random Downloads Block  (Read 22202 times)

0 Members and 1 Guest are viewing this topic.

Offline shaka

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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
5433 Views
Last post February 18, 2008, 08:03:27 am
by Ken.
4 Replies
6066 Views
Last post June 18, 2010, 09:18:00 am
by dvera
2 Replies
4819 Views
Last post November 01, 2010, 01:32:28 pm
by clothahump
1 Replies
5380 Views
Last post October 16, 2016, 12:12:51 pm
by exit
5 Replies
5328 Views
Last post July 12, 2017, 03:45:34 pm
by donk

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal