TinyPortal

Development => Block Codes => Topic started by: MTF95 on May 01, 2008, 08:22:23 AM

Title: Block for Bookmarks?
Post by: MTF95 on May 01, 2008, 08:22:23 AM
Hi!

I'm using tihs mod:
http://custom.simplemachines.org/mods/index.php?mod=864

How do I create a block which shows 5 random bookmarks that the active user has, and a link to show all bookmarks?
Title: Re: Block for Bookmarks?
Post by: Dragooon on May 01, 2008, 12:58:31 PM
This is a shot in dark, but seeing its table structure it should work
Add this in a php Block
global $ID_MEMBER, $scripturl, $db_prefix;
$request = db_query("SELECT t.ID_TOPIC, m.subject, mem.ID_MEMBER, mem.realName
FROM {$db_prefix}topics AS t
INNER JOIN {$db_prefix}bookmarks AS bm ON (bm.ID_TOPIC = t.ID_TOPIC AND bm.ID_MEMBER = $ID_MEMBER)
INNER JOIN {$db_prefix}messages AS m ON (m.ID_MSG = t.ID_FIRST_MSG)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
ORDER BY RAND()
LIMIT 5",__FILE__,__LINE__);
$topics = array();
while($row = mysql_fetch_assoc($request)) {
$topics[] = '<a href="'.$scripturl.'?topic='.$row['ID_TOPIC'].'">'.$row['subject'].'</a> by <a href="'.$scripturl.'?action=profile;u='.$row['ID_MEMBER'].'">'.$row['realName'].'</a>';
}
mysql_free_result($request);
foreach($topics as $t)
echo '<div class="smalltext">',$t,'</div>';
Title: Re: Block for Bookmarks?
Post by: MTF95 on May 01, 2008, 01:17:10 PM
I'll try that when I get my new server!
Title: Re: Block for Bookmarks?
Post by: NIBOGO on May 15, 2008, 01:51:19 AM
Quote from: Dragooon on May 01, 2008, 12:58:31 PM
This is a shot in dark, but seeing its table structure it should work
Add this in a php Block
global $ID_MEMBER, $scripturl, $db_prefix;
$request = db_query("SELECT t.ID_TOPIC, m.subject, mem.ID_MEMBER, mem.realName
FROM {$db_prefix}topics AS t
INNER JOIN {$db_prefix}bookmarks AS bm ON (bm.ID_TOPIC = t.ID_TOPIC AND bm.ID_MEMBER = $ID_MEMBER)
INNER JOIN {$db_prefix}messages AS m ON (m.ID_MSG = t.ID_FIRST_MSG)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
ORDER BY RAND()
LIMIT 5",__FILE__,__LINE__);
$topics = array();
while($row = mysql_fetch_assoc($request)) {
$topics[] = '<a href="'.$scripturl.'?topic='.$row['ID_TOPIC'].'">'.$row['subject'].'</a> by <a href="'.$scripturl.'?action=profile;u='.$row['ID_MEMBER'].'">'.$row['realName'].'</a>';
}
mysql_free_result($request);
foreach($topics as $t)
echo '<div class="smalltext">',$t,'</div>';


WOW!!! you are awesome
Title: Re: Block for Bookmarks?
Post by: MatthewSchenker on May 16, 2008, 11:00:36 PM
I don't have the Bookmark modification installed, but I would love to have a bookmark script I could add to a block in my forum.  I think being able to bookmark favorite topics is a great idea.

Is there a script I could run without installing the bookmark modification?

Thanks,
Matt
Title: Re: Block for Bookmarks?
Post by: JPDeni on May 16, 2008, 11:26:14 PM
The only script I know of is the modification. If someone were to write another script, it would be the same as the mod.
Title: Re: Block for Bookmarks?
Post by: MatthewSchenker on May 16, 2008, 11:30:42 PM
Quote from: JPDeni on May 16, 2008, 11:26:14 PM
The only script I know of is the modification. If someone were to write another script, it would be the same as the mod.

But the mod puts the "Bookmark" link in the main menu.  I was wondering how to get the "Bookmark" link to appear in a block.  Maybe in the "User" block?

I apologize if I'm missing something really obvious here!

Thanks,
Matt
Title: Re: Block for Bookmarks?
Post by: b33znutz on June 05, 2008, 02:31:46 AM
installed and works great with the mod! cheers mate! :up: :up:
Title: Re: Block for Bookmarks?
Post by: Angelotus on July 15, 2008, 09:02:48 AM
Hi, can you modifie te code for SMF 2.0?
Title: Re: Block for Bookmarks?
Post by: Dragooon on July 15, 2008, 10:42:23 AM
Eh no because there is no TP For SMF 2?
Title: Re: Block for Bookmarks?
Post by: Angelotus on July 15, 2008, 12:37:18 PM
Ew, that's true yes, I guess there will be a tp for 2.0 after a final release?
Title: Re: Block for Bookmarks?
Post by: G6Cad on July 15, 2008, 01:16:37 PM
When is the next version of TP coming out? (http://docs.tinyportal.co.uk/index.php?topic=15)

Same goes for TP for SMF2, we have not even come to an alpha stage of tp for SMF 2