SimplePortal

Customization => Blocks and Modifications => Topic started by: NIBOGO on July 16, 2010, 07:24:09 PM

Title: SMF Links Directory Block
Post 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:


Code: [Select]
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:


Code: [Select]
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);
Title: Re: SMF Links Directory Block
Post by: Nathaniel on July 16, 2010, 07:52:28 PM
Moved to the Blocks and Modifications board, thanks for the block! :)
Title: Re: SMF Links Directory Block
Post by: geekfairy on February 12, 2011, 07:30:02 PM
What would I need to change for this to work with 1.1.13?

Thanks :)
Title: Re: SMF Links Directory Block
Post by: aportadordelmix on April 23, 2011, 01:54:33 PM
(http://www.nehemoth.com/wp-content/uploads/2009/09/no-spam-logo.jpg)
Title: Re: SMF Links Directory Block
Post by: velorooms on October 04, 2012, 11:44:32 AM
works fine, but theres a problem in that it displays UNAPPROVED links which is a bit annoying.
Title: Re: SMF Links Directory Block
Post by: phantomm on October 04, 2012, 12:10:41 PM
In block code:
Code: (Find) [Select]
   SELECT id_link, name, url
Code: (Replace with) [Select]
   SELECT id_link, name, url, approved
Code: (Find) [Select]
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
Code: (Replace with) [Select]
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
if($row['approved'] == 1)

:)
Title: Re: SMF Links Directory Block
Post by: velorooms on October 07, 2012, 10:35:52 AM
gracias :D
Title: Re: SMF Links Directory Block
Post by: velorooms on January 05, 2013, 07:29:36 PM
Just for reference. Looks a lot neater with a couple of div center tags put in (vertical version)

Code: [Select]
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);
Title: Re: SMF Links Directory Block
Post by: Farjo on February 21, 2013, 12:08:22 AM
I couldn't get them to work in a horizontal block so I changed NIBOGO's code:
Code: [Select]
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%
Title: Re: SMF Links Directory Block
Post by: velorooms on March 25, 2013, 05:34:42 PM
And a straight text variation with icon.

Code: [Select]
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
SimplePortal 2.3.8 © 2008-2024, SimplePortal