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: 177
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 182
Total: 182

Author Topic: Random Downloads Block  (Read 22200 times)

0 Members and 1 Guest are viewing this topic.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Random Downloads Block
« Reply #15 on: July 01, 2012, 11:27:45 pm »
Code: [Select]
Myabe try just
[code]
global $modSettings, $smcFunc, $boardurl, $txt, $scripturl;

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


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 />';

That took the loadlanguage call[/code]
« Last Edit: July 03, 2012, 09:50:36 pm by SMFHacks »
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 #16 on: July 02, 2012, 03:32:31 am »
now get this error code showing in the block

/Sources/Load.php(2206) : eval()'d code(114) : eval()'d code on line 119

thanks for your time on this but please only when you can it is not urgent

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Random Downloads Block
« Reply #17 on: July 03, 2012, 09:50:46 pm »
Refixed the above retry again.
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 #18 on: July 04, 2012, 04:05:36 am »
it is now back to showing the full front page in the block again  >:(
« Last Edit: July 04, 2012, 04:13:50 am by shaka »

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Random Downloads Block
« Reply #19 on: July 04, 2012, 02:06:54 pm »
Not sure if this helps or not, but I have just added the following code to a php block in Simpleportal.


Code: [Select]
global $sourcedir;

loadLanguage('Downloads','english');
require_once($sourcedir . '/Downloads2.php');

Downloads_MainPageBlock('Recent Uploads', 'recent');

I get the latest uploaded files only in a block on the portal page.

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Random Downloads Block
« Reply #20 on: July 07, 2014, 02:47:17 pm »
Following on from the last post I made. This is not showing the images now for some reason in a portal block.

See what it does from the info below


Simple Portal 2.3.5 = http://www.******.net/test/thumb_1_07_07_14_12_12_46_0.jpeg - This is the properties of the link to the image.


Downloads = http://www.******.net/test/downloads/thumb_1_07_07_14_12_12_46_0.jpeg - This is the properties of the link to the image.


The code I'm using which has worked until recently is,

Code: [Select]
global $sourcedir;

loadLanguage('Downloads','english');
require_once($sourcedir . '/Downloads2.php');

Downloads_MainPageBlock('Recent Uploads', 'recent');


The error log shows

Code: [Select]
http://www.******.net/test/index.php?action=admin;area=portalblocks;sa=edit

Apply Filter: Only show the errors with the same message

8: Undefined index: down_url

Apply Filter: Only show the errors from this file

File: /home5/******/public_html/test/Sources/Downloads2.php
 Line: 6811

I have just tried this on a new clean 2.0.8 install and the only mods installed are Downloads 3.0.3 and Simple Portal 2.3.5.

The only thing that has happened recently is that the host updated the server files. What I don't understand is why the portal properties seem to leave out the 'Downloads' directory in order to find the image.

So now it's over to you :)
« Last Edit: July 08, 2014, 07:28:38 am by davejo »

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Random Downloads Block
« Reply #21 on: July 09, 2014, 03:35:03 am »
Hi VB have you any idea on this problem please?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Random Downloads Block
« Reply #22 on: July 09, 2014, 08:06:25 am »
Use this code before calling your code just in case
Code: [Select]
global $modSettings;
if (empty($modSettings['down_url']))
$modSettings['down_url'] = $boardurl . '/downloads/';
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 davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Random Downloads Block
« Reply #23 on: July 09, 2014, 11:11:23 am »
Use this code before calling your code just in case
Code: [Select]
global $modSettings;
if (empty($modSettings['down_url']))
$modSettings['down_url'] = $boardurl . '/downloads/';

Worked perfectly VB, thanks very much

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Random Downloads Block
« Reply #24 on: July 09, 2014, 12:49:29 pm »
Actually it didn't quite work perfectly but it did nearly.

It threw out an error

Code: [Select]
8: Undefined variable: boardurl

So I changed the code slightly to

Code: [Select]
global $boardurl, $modSettings;
$modSettings['down_url'] = $boardurl . '/downloads/';

global $sourcedir;

loadLanguage('Downloads','english');
require_once($sourcedir . '/Downloads2.php');

Downloads_MainPageBlock('Recent Uploads', 'recent');


and now it works with no errors.

Thanks again VB without the initial code I would never have got it working again.

Is the line
Code: [Select]
if (empty($modSettings['down_url'])) critical to it working as I am using it without and there doesn't seem to be any problems?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Random Downloads Block
« Reply #25 on: July 09, 2014, 12:56:11 pm »
No it is not critical will work fine.
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 davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Random Downloads Block
« Reply #26 on: July 09, 2014, 03:55:10 pm »
Thanks for the reply

Offline Web Presence Consulting

  • Member
  • *
  • Posts: 4
  • (T)ogether (E)veryone (A)chieves (M)ore
    • View Profile
    • Web Presence Consulting
Re: Random Downloads Block
« Reply #27 on: February 25, 2017, 05:48:16 am »
Thanks for the reply

The original request was for a block of randomly chosen items to display, I now have this working beautifully in Simple Portal block, it only requires one small edit in addition to a minor change to to the block code, as follows:

In Sources/Downloads2.php add the section circled in green to the snippet of code shown located in the Downloads_MainPageBlock() function:




After that make this minor change to the portal block code, shown in its entirety here:
Code: [Select]
global $boardurl, $modSettings;
$modSettings['down_url'] = $boardurl . '/downloads/';

global $sourcedir;

require_once($sourcedir . '/Downloads2.php');

Downloads_MainPageBlock(null, 'random');

Enjoy... I also have some custom modifications to the SMF Statistics Page that relates to various modules and SMF features, visit my site and have a look at the ones for this module, although my version of Downloads Pro is out of date, everything I've customized works great!!

« Last Edit: February 25, 2017, 06:10:21 am by Web Presence Consulting »
Best Regards,
Bob Perry




"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

 

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
6064 Views
Last post June 18, 2010, 09:18:00 am
by dvera
2 Replies
4818 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