TinyPortal

Development => Resources => Topic started by: Heero on March 09, 2008, 02:45:36 PM

Title: SMF Downloads block?
Post by: Heero on March 09, 2008, 02:45:36 PM
Hey people!
I've recently returned to Tiny Portal from MKPortal,
because Tiny Portal is a better support and addition to SMF.
Anyway,
now I am stuck with a question.

Does there already exist a block which can show the latest uploaded downloads (or something similar) from the SMF Download hack?

I've been searching around on the forums with no result,
it seems that the search doesn't filter it out.
http://custom.simplemachines.org/mods/index.php?mod=992
-> Download system.

With a friendly greet and thanks in advance  ;),
Heero
Title: Re: SMF Downloads block?
Post by: JPDeni on March 09, 2008, 03:33:42 PM
I don't think it exists.

What do you want?
Title: Re: SMF Downloads block?
Post by: Dragooon on March 09, 2008, 04:14:49 PM
OK here is a shot in the dark, I haven't tested this but give it a try


<See later posts>
Title: Re: SMF Downloads block?
Post by: Heero on March 09, 2008, 04:58:51 PM
Thank you for the replies
JPDeni,
I'd like to have a simular 'latest downloads' block as like the one from Tiny Portal.

Hey Dragooon,
thanks for your quick reply but you're shot in the dark didn't worked ;)
It makes the full page 'blank'.
Any further assistence is welcome :)

Thanks in advance,
~- Heero
Title: Re: SMF Downloads block?
Post by: JPDeni on March 09, 2008, 05:36:47 PM
Heero, can I get your example of what you want it to look like and what you want it to include? That way we'll both know that we're on the same page.
Title: Re: SMF Downloads block?
Post by: Dragooon on March 09, 2008, 05:45:48 PM
Can you tell me if any errors are there in error log?
Seems like the DB query is messed up.
Title: Re: SMF Downloads block?
Post by: Heero on March 09, 2008, 05:48:50 PM
Well of course.
Just something similar then the block :
tpmodule:
Downloads show x New Files.
Example : http://img517.imageshack.us/my.php?image=downloadsct4.jpg


Dragooon,
It gives the following error :
Table 'databaseName_smf.smf_down_files' doesn't exist
File: /home/xxx/domains/domain.org/public_html/smf/Sources/Load.php(1770) : eval()'d code(209) : eval()'d code
Line: 9

Thanks for the support again.
Title: Re: SMF Downloads block?
Post by: Dragooon on March 09, 2008, 05:52:17 PM
OK try this

<See later posts>

With some modifications it can be made like that, I'll do that tomorrow :)
Title: Re: SMF Downloads block?
Post by: Heero on March 09, 2008, 05:53:59 PM
Great, it works!
Thank You Dragooon,
also thanks for your support JPDeni.
And yeah it might be adjusted a bit, but I'm glad it works :).
Title: Re: SMF Downloads block?
Post by: Dragooon on March 09, 2008, 05:56:15 PM
Glad it worked, I'll post the code to make it look like TP's recent downloads block tomorrow.(Unless someone else does it :))
Title: Re: SMF Downloads block?
Post by: Dragooon on March 09, 2008, 06:04:43 PM
oops
Use the fol. code
global $db_prefix, $scripturl;

$request = db_query("SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.title AS ftitle,
c.title, m.realName, m.ID_MEMBER AS mID_MEMBER
FROM {$db_prefix}down_file AS f, {$db_prefix}down_cat AS c, {$db_prefix}members AS m
WHERE f.ID_CAT = c.ID_CAT
AND f.approved = '1'
AND f.ID_MEMBER = m.ID_MEMBER
ORDER BY f.ID_FILE DESC
LIMIT 5",__FILE__,__LINE__);
while($row = mysql_fetch_assoc($request)) {
echo '<div style="margin:5px"><a href="',$scripturl,'?action=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a> by <a href="',$scripturl,'?action=profile;u=',$row['mID_MEMBER'],'">',$row['realName'],'</a> in <a href="',$scripturl,'?action=viewc;id=',$row['ID_CAT'],'">',$row['title'],'</a></div>';
}

The previous ones didn't had a "limit" set to them so they would've shown all the uploads sent(I am sure you wouldn't want that :P)
Title: Re: SMF Downloads block?
Post by: JPDeni on March 09, 2008, 06:32:48 PM
glad you got it sorted. :)
Title: Re: SMF Downloads block?
Post by: Heero on March 09, 2008, 08:12:17 PM
Okay dude, thanks again!
Title: Re: SMF Downloads block?
Post by: fussilet on March 09, 2008, 08:37:25 PM
hello,
In the picture , can't you that pretend?

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Ffussilet.com%2Fdown.png&hash=5dc470e4886ff6c24aeb48b3bc0c272b262a0eaf)
Title: Re: SMF Downloads block?
Post by: Dragooon on March 10, 2008, 08:12:01 AM
I said I am gonna do that "tomorrow", so now is the tomorrow and here is the code:
global $db_prefix, $scripturl;

$request = db_query("SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.title AS ftitle, f.totaldownloads,
c.title, m.realName, m.ID_MEMBER AS mID_MEMBER
FROM {$db_prefix}down_file AS f, {$db_prefix}down_cat AS c, {$db_prefix}members AS m
WHERE f.ID_CAT = c.ID_CAT
AND f.approved = '1'
AND f.ID_MEMBER = m.ID_MEMBER
ORDER BY f.ID_FILE DESC
LIMIT 5",__FILE__,__LINE__);
while($row = mysql_fetch_assoc($request)) {
echo '<table width="100%" cellpadding="2" cellspacing="0">
<tr>
<td valign="top" class="smalltext"> <a href="',$scripturl,'?action=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a></td>
<td valign="top" class="smalltext" align="right">',$row['totaldownloads'],'</td>
</tr>
</table>';
}

Now it *should* show like TP's Recent downloads block.
Title: Re: SMF Downloads block?
Post by: fussilet on March 10, 2008, 10:49:47 AM
thank you very much, You are one piece :up
Title: Re: SMF Downloads block?
Post by: Crip on March 10, 2008, 11:01:02 AM
 
Title: Re: SMF Downloads block?
Post by: fussilet on March 10, 2008, 11:06:49 AM
thanks crip :up:  ;)
Title: Re: SMF Downloads block?
Post by: Crip on March 10, 2008, 11:08:07 AM
U bet fussilet (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fdingo.care2.com%2Fc2c%2Femoticons%2Fthumbsup.gif&hash=fa297e44b9bf26c1d5cba514c6b7166ed5403a12)
Title: Re: SMF Downloads block?
Post by: Dragooon on March 10, 2008, 11:34:37 AM
lol.....Glad it worked for you :D
It was just a *blind* shot, I don't even use that mod :P
Title: Re: SMF Downloads block?
Post by: Heero on March 10, 2008, 05:49:11 PM
Hmm yeah thanks dude!
You just fixed this up in two days :)

Although, I'd like to ask one little thing for it:
Could you fix the code,
so the block will only show the file(s) of a specific category?
Thanks in advance!

~- Heero
Title: Re: SMF Downloads block?
Post by: Dragooon on March 10, 2008, 05:55:10 PM
No problem, I love to help others and I love coding.
Use the fol. code
global $db_prefix, $scripturl;
$cats = array(1,2,3);
$request = db_query("SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.title AS ftitle, f.totaldownloads,
c.title, m.realName, m.ID_MEMBER AS mID_MEMBER
FROM {$db_prefix}down_file AS f, {$db_prefix}down_cat AS c, {$db_prefix}members AS m
WHERE f.ID_CAT = c.ID_CAT
AND f.approved = '1'
AND f.ID_MEMBER = m.ID_MEMBER
".!empty($cats) ? "AND f.ID_CAT IN('".implode(',',$cats)."')" : ''."
ORDER BY f.ID_FILE DESC
LIMIT 5",__FILE__,__LINE__);
while($row = mysql_fetch_assoc($request)) {
echo '<table width="100%" cellpadding="2" cellspacing="0">
<tr>
<td valign="top" class="smalltext"> <a href="',$scripturl,'?action=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a></td>
<td valign="top" class="smalltext" align="right">',$row['totaldownloads'],'</td>
</tr>
</table>';
}


$cats is a array, containing IDs of cats to show from
If I wrote it right, it should show from every cat if left empty.
Title: Re: SMF Downloads block?
Post by: Heero on March 10, 2008, 06:44:22 PM
Seems like it casts an error :D

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 'AND f.ID_CAT IN('1,2,3')' at line 1
File: /home/xxx/domains/domain.org/public_html/smf/Sources/Load.php(1770) : eval()'d code(209) : eval()'d code
Line: 11

And thanks again for your reply.
I really appreciate what you're doing here :)
Title: Re: SMF Downloads block?
Post by: Dragooon on March 11, 2008, 02:47:58 AM
Hmm
Try this one
global $db_prefix, $scripturl;
$cats = array(1,2,3);
$request = db_query("SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.title AS ftitle, f.totaldownloads,
c.title, m.realName, m.ID_MEMBER AS mID_MEMBER
FROM {$db_prefix}down_file AS f, {$db_prefix}down_cat AS c, {$db_prefix}members AS m
WHERE f.ID_CAT = c.ID_CAT
AND f.approved = '1'
AND f.ID_MEMBER = m.ID_MEMBER
".!empty($cats) ? "AND f.ID_CAT IN(".implode(',',$cats).")" : ''."
ORDER BY f.ID_FILE DESC
LIMIT 5",__FILE__,__LINE__);
while($row = mysql_fetch_assoc($request)) {
echo '<table width="100%" cellpadding="2" cellspacing="0">
<tr>
<td valign="top" class="smalltext"> <a href="',$scripturl,'?action=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a></td>
<td valign="top" class="smalltext" align="right">',$row['totaldownloads'],'</td>
</tr>
</table>';
}

I think it was those damn single quotes causing trouble.

If it works, make sure you enter valid Category IDs
Title: Re: SMF Downloads block?
Post by: Heero on March 11, 2008, 06:26:12 PM
Damn sorry .. :/
It still doesn't works.
It returns the following error :

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 'AND f.ID_CAT IN(1)' at line 1
File: /home/xxx/domains/domain.org/public_html/smf/Sources/Load.php(1770) : eval()'d code(209) : eval()'d code
Line: 11

damns,
Thanks again.
Title: Re: SMF Downloads block?
Post by: fussilet on March 12, 2008, 01:07:53 AM
I corrected the council...

code :
Quote<a href="',$scripturl,'?action=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a>

I exchanged

Quote<a href="',$scripturl,'?action=downloads;sa=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a>
Title: Re: SMF Downloads block?
Post by: Dragooon on March 12, 2008, 07:45:42 AM
Can't seem to figure out what Is wrong, I'll see to it later :)
Title: Re: SMF Downloads block?
Post by: fussilet on March 12, 2008, 03:57:33 PM
Now, There isn't the problem  ;)
Title: Re: SMF Downloads block?
Post by: Dragooon on March 12, 2008, 04:27:43 PM
I wasn't talking about that, I was talking about showing from specific categories.
And can you remove the [color=red BBC tags since in Code block the other BBC doesn't works.
Title: Re: SMF Downloads block?
Post by: Heero on March 12, 2008, 10:02:05 PM
Well fussilet check what Dragooon said,
The code works, but showing specific categories fails somehow and returns an error O.o!
Title: Re: SMF Downloads block?
Post by: G6Cad on March 12, 2008, 10:17:08 PM
I removed the color red code, hope it helps
Title: Re: SMF Downloads block?
Post by: Heero on March 12, 2008, 10:45:33 PM
Thanks G6,
Yet it shouldn't be
<a href="',$scripturl,'?action=downloads;sa=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'[/URL]

It should be
<a href="',$scripturl,'?action=downloads;sa=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a>

[/URL] = </a>

Well hmm ..
It still doesn't work over here :/

Error :
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 'AND f.ID_CAT IN(1)' at line 1
File: /home/xxx/domains/domain.org/public_html/smf/Sources/Load.php(1770) : eval()'d code(209) : eval()'d code
Line: 11
Title: Re: SMF Downloads block?
Post by: Dragooon on March 13, 2008, 04:06:54 AM
That has NOTHING to do with that problem......
I'll work on it later, currently I am out of time.
Title: Re: SMF Downloads block?
Post by: Dragooon on March 13, 2008, 04:33:41 AM
This should work
global $db_prefix, $scripturl;
$cats = array();
$cat = implode(',',$cats);
$categories = '';
if(!empty($cats))
$categories = "AND f.ID_CAT IN($cat)";
$request = db_query("SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.title AS ftitle, f.totaldownloads,
c.title, m.realName, m.ID_MEMBER AS mID_MEMBER
FROM {$db_prefix}down_file AS f, {$db_prefix}down_cat AS c, {$db_prefix}members AS m
WHERE f.ID_CAT = c.ID_CAT
AND f.approved = '1'
AND f.ID_MEMBER = m.ID_MEMBER
$categories
ORDER BY f.ID_FILE DESC
LIMIT 5",__FILE__,__LINE__);
while($row = mysql_fetch_assoc($request)) {
echo '<table width="100%" cellpadding="2" cellspacing="0">
<tr>
<td valign="top" class="smalltext"> <a href="',$scripturl,'?action=downloads;sa=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a></td>
<td valign="top" class="smalltext" align="right">',$row['totaldownloads'],'</td>
</tr>
</table>';
}
Title: Re: SMF Downloads block?
Post by: Heero on March 13, 2008, 08:30:23 AM
Yeah it works!
Thanks Dragooon!
Title: Re: SMF Downloads block?
Post by: Dragooon on March 13, 2008, 08:36:51 AM
Glad it finally worked out :p
I think I should start testing my codes before posting :P
Title: Re: SMF Downloads block?
Post by: IchBin on March 13, 2008, 02:03:02 PM
Quote from: Dragooon on March 13, 2008, 08:36:51 AM
Glad it finally worked out :p
I think I should start testing my codes before posting :P
What a novel idea... lol
Title: Re: SMF Downloads block?
Post by: Dragooon on March 13, 2008, 04:01:06 PM
You mean "nobel"?
lol Thanks :P
Title: Re: SMF Downloads block?
Post by: Zetan on March 13, 2008, 04:03:51 PM
Nope.. I think he means >> "novel (http://www.thefreedictionary.com/novel)" << Adj. 2  :P
Title: Re: SMF Downloads block?
Post by: IchBin on March 13, 2008, 09:19:29 PM
Quote from: ZTN on March 13, 2008, 04:03:51 PM
Nope.. I think he means >> "novel (http://www.thefreedictionary.com/novel)" << Adj. 2  :P
Ding! Thats 10 points for Zetan!
Title: Re: SMF Downloads block?
Post by: Talliostro on June 06, 2008, 12:11:58 PM
hi there.
this little snippet works well on my site, but is there a way to sort the downloads with "most popular" instead of "last uploaded"?

I think this is the line
ORDER BY f.ID_FILE DESC

so what do I have to change if I want to display the most popular downloads?

:)

EDIT:
Nevermind. got it by myself it's
ORDER BY f.totaldownloads DESC