collapse collapse

* User Info

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

* Who's Online

  • Dot Guests: 187
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM
Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: A Better Recent Topics  (Read 14313 times)

0 Members and 1 Guest are viewing this topic.

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
A Better Recent Topics
« on: March 03, 2009, 06:53:46 PM »
[FOR SMF 2.0 ONLY]

Hi,

I wanted to exclude some boards from the normal recent topics. I didn't know how then I tried to understand how php for smf works. Well... I understood and I did some modifications to recent topics. Here is a demo:


1- Img of your choice
2- Subject from the topic
3- How many people saw?
4- Last Member who posted
5- How many people comment?
6- Category
7- Title of your choice
8- If you have the mod "Thank-o-matic" it says how many thank you was given to the topic

To change point 1 find (and replace YOUR URL):
Code: [Select]
<td valign="middle"><img src="YOUR URL" border="0" /></td>
To change point 7 find (and replace YOUR TEXT):
Code: [Select]
<td valign="middle" width="100%" style="padding: 5px;"> YOUR TEXT
If you want to translate the mod to your language find (and replace posted by, in, visits and comments to your language):
Code: [Select]
<div style="font-size: 9px;">Posted by ', $post['poster']['link'], ' in ', $post['board']['link'], ' | ', $post['time'], '
<div style="font-size: 9px;">
<i>(Visits: ', $post['views'], ' | Comments: ', $post['replies'], ')</i></font>

If you want to limit the block to some boards find:
Code: [Select]
$exclude_boards = null;
and replace to:
Code: [Select]
$exclude_boards = array(IDBLOCK1, IDBLOCK2);where IDBLOCK1 and IDBLOCK2 are your board's ID that you want to exclude.

If you want to limit your block to show only X topics find:
Code: [Select]
$num_recent = !empty($parameters[0]) ? $parameters[0] :  (isset($_GET['limit']) ? (int) $_GET['limit'] : 5);
and replace 5 to the number that you want

Finally,
Here is the code (without mod for Thank-o-matic)
Code: [Select]
global $context, $settings, $scripturl, $txt;
global $user_info, $modSettings, $smcFunc, $posts;
global $color_profile;

$exclude_boards = null;
$num_recent = !empty($parameters[0]) ? $parameters[0] :  (isset($_GET['limit']) ? (int) $_GET['limit'] : 5);

if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = $smcFunc['db_query']('','
SELECT
m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, t.num_replies, t.num_views, b.name AS bName,
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.ID_MSG, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ', LEFT(m.body, 384) AS body, m.smileys_enabled, m.icon
FROM ({db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}boards AS b, {db_prefix}messages AS ms)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:id_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:id_member})' : '') . '
WHERE t.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . '
AND t.id_last_msg = m.id_msg
AND b.id_board = t.id_board' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})'). '
AND {raw:query_see_board}
AND ms.id_msg = t.id_last_msg
ORDER BY t.id_last_msg DESC
LIMIT {int:limit}',
array(
'id_member' => $user_info['id'],
'exclude_boards' => $exclude_boards,
'query_see_board' => $user_info['query_wanna_see_board'],
'limit' => (int) $num_recent,
)
);
$posts = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '&#10;')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

//Collect the color ids :)
$colorids[$row['id_member']] = $row['id_member'];

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['id_board'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['is_read']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
'views' => $row['num_views'],
'replies' => $row['num_replies'],
);
}
$smcFunc['db_free_result']($request);

// Load recent topic posts colors =)
if(!empty($colorids) && sp_loadColors($colorids) !== false)
foreach($posts as $k => $p)
if(!empty($color_profile[$p['poster']['id']]['link']))
$posts[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];

$context['recent_topics']=$posts;

// Just return it.
if (empty($posts))
return $posts;

echo '
<div class="tborder">
<table cellspacing="0" width="100%">
<tr class="catbg">
<td valign="middle"><img src="YOUR URL" border="0" /></td>
<td valign="middle" width="100%" style="padding: 5px;"> YOUR TEXT
</tr>
<tr>
<td style="padding: 5px;">
</td>';
foreach ($posts as $post)
echo '
<tr>
<td align="center" valign="middle" nowrap="nowrap">
', $post['icon'], '
</td>
<td valign="middle" width="%100">
<div style="font-size: 12px;"><b>
<a href="', $post['href'], '">', $post['subject'], '</a>
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '</b></div><div style="font-size: 9px;">Posted by ', $post['poster']['link'], ' in ', $post['board']['link'], ' | ', $post['time'], '
<div style="font-size: 9px;">
<i>(Visits: ', $post['views'], ' | Comments: ', $post['replies'], ')</i></font>
</td>
</tr>';
echo '
</table></div>';

Here is the code (with mod for Thank-o-matic)
Code: [Select]
global $context, $settings, $scripturl, $txt;
global $user_info, $modSettings, $smcFunc, $posts;
global $color_profile;

$exclude_boards = null;
$num_recent = !empty($parameters[0]) ? $parameters[0] :  (isset($_GET['limit']) ? (int) $_GET['limit'] : 5);

if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = $smcFunc['db_query']('','
SELECT
m.poster_time, ms.subject, m.thank_you_post_counter, m.id_topic, m.id_member, m.id_msg, b.id_board, t.num_replies, t.num_views, b.name AS bName,
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.ID_MSG, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ', LEFT(m.body, 384) AS body, m.smileys_enabled, m.icon
FROM ({db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}boards AS b, {db_prefix}messages AS ms)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:id_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:id_member})' : '') . '
WHERE t.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . '
AND t.id_last_msg = m.id_msg
AND b.id_board = t.id_board' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})'). '
AND {raw:query_see_board}
AND ms.id_msg = t.id_last_msg
ORDER BY t.id_last_msg DESC
LIMIT {int:limit}',
array(
'id_member' => $user_info['id'],
'exclude_boards' => $exclude_boards,
'query_see_board' => $user_info['query_wanna_see_board'],
'limit' => (int) $num_recent,
)
);
$posts = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '&#10;')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

//Collect the color ids :)
$colorids[$row['id_member']] = $row['id_member'];

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['id_board'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['is_read']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
'views' => $row['num_views'],
'replies' => $row['num_replies'],
'thankyou' => $row['thank_you_post_counter'],
);
}
$smcFunc['db_free_result']($request);

// Load recent topic posts colors =)
if(!empty($colorids) && sp_loadColors($colorids) !== false)
foreach($posts as $k => $p)
if(!empty($color_profile[$p['poster']['id']]['link']))
$posts[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];

$context['recent_topics']=$posts;

// Just return it.
if (empty($posts))
return $posts;

echo '
<div class="tborder">
<table cellspacing="0" width="100%">
<tr class="catbg">
<td valign="middle"><img src="YOUR URL" border="0" /></td>
<td valign="middle" width="100%" style="padding: 5px;"> YOUR TEXT
</tr>
<tr>
<td style="padding: 5px;">
</td>';
foreach ($posts as $post)
echo '
<tr>
<td align="center" valign="middle" nowrap="nowrap">
', $post['icon'], '
</td>
<td valign="middle" width="%100">
<div style="font-size: 12px;"><b>
<a href="', $post['href'], '">', $post['subject'], '</a>
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '</b></div><div style="font-size: 9px;">Posted by ', $post['poster']['link'], ' in ', $post['board']['link'], ' | ', $post['time'], '
<div style="font-size: 9px;">
<i>(Visits: ', $post['views'], ' | Comments: ', $post['replies'], ' | Thank you: ', $post['thankyou'], ')</i></font>
</td>
</tr>';
echo '
</table></div>';;


Hope you like it  ;D

EDIT: Oh! It's for SMF 2.0. Don't know if it works on SMF 1.1.x though.
« Last Edit: May 07, 2009, 01:38:35 PM by Blue »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline fotografo74

  • Jr. Member
  • **
  • Posts: 51
  • SMF Version: 2 RC1-1
  • SP Version: 2.3
Re: [MOD] A Better Recent Topics
« Reply #1 on: March 04, 2009, 09:30:17 AM »
Thanks :-)
Can you please attach bigger example image ?
Antonio

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [MOD] A Better Recent Topics
« Reply #2 on: March 04, 2009, 07:57:58 PM »
Yes I can António. Here it is ;)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline fotografo74

  • Jr. Member
  • **
  • Posts: 51
  • SMF Version: 2 RC1-1
  • SP Version: 2.3
Re: [MOD] A Better Recent Topics
« Reply #3 on: March 05, 2009, 02:35:43 AM »
Yes I can António. Here it is ;)
Thanks!
It's a nice Mod ! :-)
Antonio

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [MOD] A Better Recent Topics
« Reply #4 on: March 05, 2009, 03:45:47 PM »
Thanks :) It's my first mod eheh! :P

Is it working fine with you? ;)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline necrit

  • Newbie
  • Posts: 3
  • SMF Version: 2 RC1
  • SP Version: 2.2
Re: A Better Recent Topics
« Reply #5 on: April 28, 2009, 06:35:58 PM »
So this is all very hard coded then?  Will there be anyway to specify the boards wanted by using the convenient block edit section of the configuration panel?  Figured it out.  my post is in the custom coding section http://simpleportal.net/index.php?topic=2132.0
« Last Edit: April 29, 2009, 03:45:54 PM by necrit »

Offline SAFAD

  • Just Registered
  • Posts: 1
  • SMF Version: 1.1.9
  • SP Version: 2.2.2
Re: A Better Recent Topics
« Reply #6 on: April 12, 2010, 01:30:41 AM »
it says wrong code
even when iparsed it in standalone php file
maybe its bug in simpleportal ?

Offline Afro

  • Semi Newbie
  • *
  • Posts: 37
    • The African Forum
  • SMF Version: 2.0.11
  • SP Version: 2.3.2
Re: A Better Recent Topics
« Reply #7 on: April 30, 2010, 10:55:13 AM »
This is a very nice twist.

Is there a way to remove the "RE" prefix in front of updates topics ?

Offline SteveW

  • Semi Newbie
  • *
  • Posts: 6
  • SMF Version: 2 RC1
  • SP Version: 2.2.1
Re: A Better Recent Topics
« Reply #8 on: November 21, 2010, 06:05:43 AM »
Hi - this is a very good block! :)

I would like to display this block in a table but I am struggling to alter the original code to fit into these:

Code: [Select]
<table align="center" border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
<tbody>
<tr>
<td style="text-align: center;">
CODE 1</td>
<td style="text-align: center;">
CODE 2</td>
</tr>
<tr>
<td style="text-align: center;">
CODE 3</td>
<td style="text-align: center;">
CODE 4</td>
</tr>
<tr>
<td style="text-align: center;">
CODE 5</td>
<td style="text-align: center;">
CODE 6</td>
</tr>
</tbody>
</table>


I have given it a go but if someone can help that would be fantastic!  ;)

Offline NCSurfer

  • Newbie
  • Posts: 2
  • SMF Version: 1.1.10
  • SP Version: 2.3
Re: A Better Recent Topics
« Reply #9 on: July 09, 2011, 09:48:33 AM »
How do I change the color of the text in Point 7 without making the changes throughout the entire theme.

I tried... <td valign="middle" width="100%" color="red" style="padding: 5px;">
« Last Edit: July 09, 2011, 09:51:19 AM by NCSurfer »

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: A Better Recent Topics
« Reply #10 on: July 09, 2011, 10:39:46 AM »
Replace with:

Code: [Select]
<td valign="middle" width="100%" style="color:red;padding: 5px;">
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline NCSurfer

  • Newbie
  • Posts: 2
  • SMF Version: 1.1.10
  • SP Version: 2.3
Re: A Better Recent Topics
« Reply #11 on: July 09, 2011, 10:47:17 AM »
Worked great, ty

Offline gumis_rulez

  • Semi Newbie
  • *
  • Posts: 13
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: A Better Recent Topics
« Reply #12 on: September 22, 2011, 03:23:46 PM »
I am interested in adding only point 5 from your list:

Quote
5- How many people comment?

What should i change and in which file (because this information i didn;t find).

Maybe you could help me with these ads to recent topics:http://simpleportal.net/index.php?topic=9731.0