SimplePortal
Customization => Blocks and Modifications => Topic started by: NIBOGO on July 16, 2010, 07:24:09 PM
-
SMF 2.0 Block for SMF Links Directory (http://www.smfpacks.com/index.php?action=page;sa=ld)
Horizontal:
global $smcFunc, $scripturl;
echo'Recent Links:<br />';
$dbresult = $smcFunc['db_query']('', '
SELECT id_link, name, url
FROM {db_prefix}links
ORDER BY id_link DESC
LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo'<a href="'.$scripturl.'?action=links;sa=details;lid='.$row['id_link'].'"><img src="http://open.thumbshots.org/image.aspx?url='.$row['url'].'" alt="'.$row['name'].'" /><br />'.$row['name'].'</a>';
}
$smcFunc['db_free_result']($dbresult);
Vertical:
global $smcFunc, $scripturl;
echo'Recent Links:<br />';
$dbresult = $smcFunc['db_query']('', '
SELECT id_link, name, url
FROM {db_prefix}links
ORDER BY id_link DESC
LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo'<a href="'.$scripturl.'?action=links;sa=details;lid='.$row['id_link'].'"><img src="http://open.thumbshots.org/image.aspx?url='.$row['url'].'" alt="'.$row['name'].'" /><br />'.$row['name'].'</a><br />';
}
$smcFunc['db_free_result']($dbresult);
-
Moved to the Blocks and Modifications board, thanks for the block! :)
-
What would I need to change for this to work with 1.1.13?
Thanks :)
-
(http://www.nehemoth.com/wp-content/uploads/2009/09/no-spam-logo.jpg)
-
works fine, but theres a problem in that it displays UNAPPROVED links which is a bit annoying.
-
In block code:
SELECT id_link, name, url
SELECT id_link, name, url, approved
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
if($row['approved'] == 1)
:)
-
gracias :D
-
Just for reference. Looks a lot neater with a couple of div center tags put in (vertical version)
global $smcFunc, $scripturl;
$dbresult = $smcFunc['db_query']('', '
SELECT id_link, name, url
FROM {db_prefix}links
ORDER BY id_link DESC
LIMIT 3');
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo'<a href="'.$scripturl.'?action=links;sa=details;lid='.$row['id_link'].'"><div align="center"><img src="http://open.thumbshots.org/image.aspx?url='.$row['url'].'" alt="'.$row['name'].'" /></div><div align="center">'.$row['name'].'</div></a>';
}
$smcFunc['db_free_result']($dbresult);
-
I couldn't get them to work in a horizontal block so I changed NIBOGO's code:
global $smcFunc, $scripturl;
echo'<ul>';
$dbresult = $smcFunc['db_query']('', '
SELECT id_link, name, url
FROM {db_prefix}links
ORDER BY id_link DESC
LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo'<li style="display: inline-block; text-align:center; width: 20%"><a href="'.$scripturl.'?action=links;sa=details;lid='.$row['id_link'].'"><img src="http://open.thumbshots.org/image.aspx?url='.$row['url'].'" alt="'.$row['name'].'" /><br />'.$row['name'].'</a></li>';
}
$smcFunc['db_free_result']($dbresult);
echo '</ul>';
It picks out the latest 5 links, so the width of each list item is 20%
-
And a straight text variation with icon.
global $smcFunc, $scripturl;
$dbresult = $smcFunc['db_query']('', '
SELECT id_link, name, url
FROM {db_prefix}links
ORDER BY id_link DESC
LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo'<img src="/Themes/default/images/sp/linkicon.png" /><a href="'.$scripturl.'?action=links;sa=details;lid='.$row['id_link'].'">'.$row['name'].'</a><br/>';
}
$smcFunc['db_free_result']($dbresult);
need to upload the attached image to sp images directory