TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

June 17, 2024, 06:55:42 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,254
  • Total Topics: 21,225
  • Online today: 149
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 127
  • Total: 127

Last Upload Block

Started by GTS, June 21, 2006, 07:55:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GTS

Hi there.

Since the release of the next TP version will probably still take a while, i've made a block similar to the "Last Upload" block on the left side here, myself.
It has less info as the one here, but at least i now have the latest file on my frontpage :D

The following code has to be in a phpbox:

$tp_prefix=$settings['tp_prefix'];

$request = db_query("SELECT * FROM {$tp_prefix}dlmanager WHERE type = 'dlitem' ORDER BY 'created' DESC LIMIT 1", __FILE__, __LINE__);
$row=mysql_fetch_array($request);

echo "<a href=\"?action=tpmod;dl=get". $row['id'] ."\"><img src=\"". $row['icon']."\" /></a><br />";
echo "<b><a href=\"?action=tpmod;dl=get". $row['id'] ."\">". $row['name'] ."</a></b>";
echo "<hr />";
echo "<font size=\"1\">Uploaded: <br />";
echo "<i>". timeformat($row['created']) ."</i><br />";
echo "Downloads: <b>". $row['downloads'] ."</b><br />";
echo "Views: <b>". $row['views'] ."</b><br />";
echo "</font>";


You also could change it to a "most popular file" block by simply replacing the line
$request = db_query("SELECT * FROM {$tp_prefix}dlmanager WHERE type = 'dlitem' ORDER BY 'created' DESC LIMIT 1", __FILE__, __LINE__);

with
$request = db_query("SELECT * FROM {$tp_prefix}dlmanager WHERE type = 'dlitem' ORDER BY 'downloads' DESC LIMIT 1", __FILE__, __LINE__);


And, if you don't want to link direclty to the file, but to the details page of the file, you need to replace the line:
echo "<b><a href=\"?action=tpmod;dl=get". $row['id'] ."\">". $row['name'] ."</a></b>";

with
echo "<b><a href=\"?action=tpmod;dl=item". $row['id'] ."\">". $row['name'] ."</a></b>";


You can see it in action on the page in my signature :)

Regards,

GTS

Edit: added some customizations

bloc

Nice. :)

This is pretty much how the new blocktype "modules" works too. You can have last upload, most downloaded or most viewed. Either one file or a listing. :)

Crip

That's a nifty block..php power to ya! ;)
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



stormlrd

Slick one of the things I want to smooth out is the download section on my forum along with a themeshop plugin hint hint :P

Crip

Quote from: StormLrd on June 22, 2006, 11:05:55 AM
Slick one of the things I want to smooth out is the download section on my forum along with a themeshop plugin hint hint :P

You will like TP_v0.9.5 - it's awesome! :up: :coolsmiley:
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



stormlrd

Quote from: crip on June 22, 2006, 12:03:54 PM
You will like TP_v0.9.5 - it's awesome! :up: :coolsmiley:

Yes Im enjoying it so far lol :D

GTS

Heheh, getting complimented now and then sure is nice ;)

Quote from: StormLrd on June 22, 2006, 12:08:18 PM
Quote from: crip on June 22, 2006, 12:03:54 PM
You will like TP_v0.9.5 - it's awesome! :up: :coolsmiley:

Yes Im enjoying it so far lol :D

bah, i want it too :D

erikman


alhaudhie

i try to change DESC LIMIT 1", __FILE__, __LINE__); to show 2 latests upload file.. but failed.. anybody can suggest the right way?

DESC LIMIT 2", __FILE__, __LINE__);

IchBin

If you have more than one result you need to run it through a loop.
$tp_prefix=$settings['tp_prefix'];

$request = db_query("SELECT * FROM {$tp_prefix}dlmanager WHERE type = 'dlitem' ORDER BY 'created' DESC LIMIT 2", __FILE__, __LINE__);
$rows=mysql_fetch_array($request);

foreach ($rows as $row)
{
echo "<a href=\"?action=tpmod;dl=get". $row['id'] ."\"><img src=\"". $row['icon']."\" /></a><br />";
echo "<b><a href=\"?action=tpmod;dl=get". $row['id'] ."\">". $row['name'] ."</a></b>";
echo "<hr />";
echo "<font size=\"1\">Uploaded: <br />";
echo "<i>". timeformat($row['created']) ."</i><br />";
echo "Downloads: <b>". $row['downloads'] ."</b><br />";
echo "Views: <b>". $row['views'] ."</b><br />";
echo "</font>";
}