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
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. :)
That's a nifty block..php power to ya! ;)
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
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:
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
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
Great script, GTS :D :D
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__);
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>";
}