Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4257
Latest: Alex998.
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43295
Total Topics: 7523
Most Online Today: 344
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 241
Total: 241

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Pegasys

Pages: [1]
1
Feature Requests / Downloads Portal Block
« on: March 31, 2010, 07:55:00 pm »
* This is not a feature request... but it seemed to be the most appropriate forum to put it in. Staff... please feel free to relocate as required.


If you use any of the portal systems for SMF that have PHP blocks, you can easily duplicate the Recent Downloads section of the Downloads System on your Front Page.


Just add the following code snippet into a portal PHP block:

Code: [Select]
global $sourcedir;

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

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


function GetStarsByPrecent($percent)
{
global $settings, $txt;

$s = '<span style="white-space: nowrap;">';

if ($percent == 0)
return $txt['downloads_text_catnone'];
else if ($percent <= 20)
return $s . str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 1) . '</span>';
else if ($percent <= 40)
return $s . str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 2) . '</span>';
else if ($percent <= 60)
return $s . str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 3) . '</span>';
else if ($percent <= 80)
return $s . str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 4) . '</span>';
else if ($percent <= 100)
return $s . str_repeat('<img src="' . $settings['images_url'] . '/star.gif" alt="*" border="0" />', 5) . '</span>';
}


Options:

If you would rather have the Most Viewed, Most Commented On, Most Downloaded, or Top Rated  downloads display, just change the 'recent' string in the function call  ( MainPageBlock('Recent Uploads', 'recent'); ) to either 'viewed', 'mostcomments', 'mostdownloaded' or 'toprated'.

* You will also want to change the title string in the function call ( MainPageBlock('Recent Uploads', 'recent'); ) to match what ever function you are calling (eg.. 'Most Viewed Downloads'.. or 'Top Rated Downloads', etc...


If you would like more than one or all of the options to display, just duplicate the function call... and add at least one line break ( eg..  echo '<br />';  ) between them. So you would have the function call like this:

Code: [Select]
//Example Only...

    MainPageBlock('Recent Uploads', 'recent');
    echo '<br />';
    MainPageBlock('Highest Rated Downloads', 'toprated');
    echo '<br />';

   //.... etc,


How It Works:

Very little code is required because the block simply uses the code already provided by the Downloads System program. The  require_once($sourcedir . '/Downloads2.php')  loads in the Downloads System main file so we can use the MainPageBlock function it contains. That function has all the database query code and data output formatting in it... so we don't have to include it. Just once function call... and our work here is done. Miller time!!   ;D

The MainPageBlock function, however, does make a function call to the GetStarsByPrecent function which, I know not why, is in the Downloads System template file. Instead of including that rather large file as we did with the Downloads main file, I just copied that fairly small function and pasted it into our block.



NOTES:

* This was designed and tested for the Downloads System (non-pro) version 1.3... running on SMF 2.0 RC3. I would think it would also function properly on older versions as well as the pro version... but don't hold me to that.

* The GetStarsByPrecent function includes a small modification I added where the star images are enclosed in a <span> element with a "white-space: nowrap" property to keep the star images together and prevent them from wrapping if the browser width is reduced too far.

* Because of the width of the display, this code snippet in not suitable for use in a normal left or right pane block.



CREDITS:

* All of the code used in the snippet (well, 99% of it anyway) is code included or copied from the SMF Hacks Downloads System files. All copyrights, I assume... apply. As this code would be useless without that system installed, I believe you can safely use this snippet without violating any copyright or the intent thereof.



2
Support / Importing TP Portal Files Error
« on: February 21, 2010, 11:41:41 pm »
I am getting the following error when trying to import download file from TP Portal:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3
File: /home/jphayden/public_html/forum2/Sources/Downloads2.php
Line: 5478



The code in question (lines 5476-5478) from the Downloads2.php file is:

Code: [Select]
// Insert the category
$smcFunc['db_query']('',"INSERT INTO smf_down_cat
(title, description, ID_PARENT)
VALUES ('$title', '$description',$ID_PARENT)");


I suspected that it might be an errant or missing single quote... something obvious. I also noticed that the field name in the database for ID_PARENT is lower case, not upper case. Tried changing that but no luck.  I'm clueless on this one.

Help please.



Pages: [1]

+- Recent Topics

Please Help! by SMFHacks
April 17, 2024, 08:04:55 am

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

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

Powered by EzPortal