Twitter SMFHacks Facebook SMFHacks SMFHacks.com
** Home Forum Index Hacks Products Login Register Search
Welcome, Guest. Please login or register.
May 19, 2013, 02:05:25 pm

Login with username, password and session length
Members
Total Members: 10758
Latest: murdocklawless
Stats
Total Posts: 32349
Total Topics: 5474
Online Today: 60
Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Users: 0
Guests: 46
Total: 46
+ 
|-+ 
| |-+ 
| | |-+ 
| | | |-+ 
| | | | |-+ 
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Go Down Print
Author Topic: Random Downloads Block  (Read 3057 times)
shaka
Inline PM Customer
*****
Offline Offline

Posts: 37


View Profile
« 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

Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« 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.
Logged
shaka
Inline PM Customer
*****
Offline Offline

Posts: 37


View Profile
« 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
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« Reply #3 on: June 27, 2012, 11:31:02 am »

Last question forgot to ask what SMF version are you using?
Logged
shaka
Inline PM Customer
*****
Offline Offline

Posts: 37


View Profile
« Reply #4 on: June 27, 2012, 12:38:17 pm »

SMF 2.0.2

thanks
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« Reply #5 on: June 27, 2012, 02:15:03 pm »

Try this
Code:

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 />';
Logged
shaka
Inline PM Customer
*****
Offline Offline

Posts: 37


View Profile
« Reply #6 on: June 27, 2012, 04:51:03 pm »

doesn't work just adds my whole front page into the block
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« Reply #7 on: June 27, 2012, 04:55:45 pm »

Link to the block/issue?
Logged
shaka
Inline PM Customer
*****
Offline Offline

Posts: 37


View Profile
« Reply #8 on: June 28, 2012, 04:41:16 am »

Hi I have attached 2 screenshots 1 with the code 1 without the code

Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« Reply #9 on: June 28, 2012, 10:13:29 am »

Any errors in the forum error log?
Logged
shaka
Inline PM Customer
*****
Offline Offline

Posts: 37


View Profile
« Reply #10 on: June 29, 2012, 01:47:10 am »

Undefined index: ezp_pagemanager
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« 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.
Logged
shaka
Inline PM Customer
*****
Offline Offline

Posts: 37


View Profile
« 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
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« Reply #13 on: July 01, 2012, 06:18:15 pm »

How are you inserting the code?
Logged
shaka
Inline PM Customer
*****
Offline Offline

Posts: 37


View Profile
« Reply #14 on: July 01, 2012, 11:12:59 pm »

tiny portal PHP block with frame style from theme selected
Logged
Pages: [1] 2 Go Up Print 
« previous next »
Jump to:  

Recent
[Today at 07:03:27 am]

[May 16, 2013, 10:13:46 pm]

[May 15, 2013, 11:32:14 pm]

[May 15, 2013, 11:31:24 pm]

[May 12, 2013, 09:10:43 am]

[May 10, 2013, 03:49:55 am]

[May 07, 2013, 07:12:40 pm]

[May 07, 2013, 02:37:14 pm]

[May 06, 2013, 10:29:56 pm]

[May 04, 2013, 03:22:01 pm]
Random Picture
Donate to SMFHacks.com
Help Support the SMFHacks.com mod making.
Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
TinyPortal v0.9.7 © Bloc
SMF and SimpleMachines are registered trademarks of Simple Machines. SMFHacks.com is not affiliated with nor endorsed by Simple Machines.
Page created in 1.292 seconds with 21 queries.