TinyPortal

Development => Support => Topic started by: PureLoneWolf on July 22, 2012, 04:18:27 PM

Title: [SOLVED]Sort Download Items by Number of Downloads
Post by: PureLoneWolf on July 22, 2012, 04:18:27 PM
Link to my site: http://www.resurrectionremix.com
SMF version: SMF 2.0.2
TP version: 1.0 Final
Default Forum Language: English
Theme name and version: Curve
Mods installed: TinyPortal, Ohara Youtube Embed, Tapatalk SMF 2.0 RC4/RC5/Final Plugin, FAQ Mod, SMF Gallery Lite, Attention Lost Topic, Discourage IE6, Hide IP for users, seperate sticky topics, signature area BBCode, Smart Pagination, Sneaky Editing, Topic Rating Bar, Thank-O-Matic, BBC Spoiler, RSS Feed Icon


Hi there

Is it possible to sort the download items by the number of downloads (highest to lowest)?

I saw this http://www.tinyportal.net/index.php?topic=18798.msg154366#msg154366 but there are so many ORDER BY statements and I only want to do this for download items, not categories.

I assume that I would change "name" to "downloads" and ASC to DESC, but as I said, I don't see which lines I should be changing in TPdlmanager.php

Is this something someone could help with?

Thanks in advance
Title: Re: Sort Download Items by Number of Downloads
Post by: IchBin on July 23, 2012, 09:18:18 PM
Do you mean when you have multiple items under the same download? I'm not sure I'm following your description.
Title: Re: Sort Download Items by Number of Downloads
Post by: PureLoneWolf on July 23, 2012, 09:23:49 PM
Lets say I have a category called Mods - I have manually positioned this as 2nd in my category list and that is absolutely spot on.

When I go into the Mods category - There are 5 files available to download, that have all been downloaded multiple times, but they are displayed by uploaded item number (I think)

So I get

Item 1 - 20 downloads
Item 2 - 4 downloads
Item 3 - 300 downloads
Item 4 - 800 downloads
Item 5 - 48 downloads

I would like for them to be sorted by the amount of downloads they have - so the above would display:

Item 4 - 800 downloads
Item 3 - 300 downloads
Item 5 - 48 downloads
Item 1 - 20 downloads
Item 2 - 4 downloads

And if Item 1 increased to 50, I would see:

Item 4 - 800 downloads
Item 3 - 300 downloads
Item 1 - 50 downloads
Item 5 - 48 downloads
Item 2 - 4 downloads

Hopefully that makes it clearer, apologies for any confusion

Thanks
Title: Re: Sort Download Items by Number of Downloads
Post by: IchBin on July 23, 2012, 10:39:11 PM
Ah, so items in the category then. That shouldn't be hard. I'll take a look at the code when I get a free moment here.
Title: Re: Sort Download Items by Number of Downloads
Post by: IchBin on July 24, 2012, 03:36:01 AM
In Sources/TPdlmanager.php around line #808 find this code:
$context['TPortal']['dlsort'] = $dlsort = 'id';

Change it to this:
$context['TPortal']['dlsort'] = $dlsort = 'downloads';
Title: Re: Sort Download Items by Number of Downloads
Post by: PureLoneWolf on July 25, 2012, 06:18:24 PM
That seemed to do the trick :)

Thanks again :D